WHMCS技巧:使用第三方SMTP服务器代发邮件

2018年10月11日 | 分类: 【源码】

【排错】

当WHMCS的管理面板中2处发送人电邮地址不一致,将会报错:

There has been an error sending the message. The following From address failed: support@name.com : MAIL FROM command failed,mail from address must be same as authorization user ,501,SMTP server error: MAIL FROM command failed Detail: mail from address must be same as authorization user SMTP code: 501SMTP server error: MAIL FROM command failed Detail: mail from address must be same as authorization user SMTP code: 501 

如果失败,PHPMailer将无法发送电子邮件,报错:

SMTP connect() failed

【服务商】

网易邮箱SMTP:

实证成功。

配置:

常规》WHMCS默认的发件邮箱地址:postmaster@163.com
邮件类型:SMTP
邮件编码:8bit
SMTP端口:465
SMTP主机名:smtp.163.com
SMTP用户名:postmaster
SMTP密码:163邮箱分配的TOKEN(授权码)
SMTP的SSL类型:SSL
系统邮箱名:postmaster@163.com

QQ邮箱SMTP:

实证成功。

常规》WHMCS默认的发件邮箱地址:postmaster@qq.com
邮件类型:SMTP
邮件编码:8bit
SMTP端口:587
SMTP主机名:smtp.qq.com
SMTP用户名:postmaster@qq.com
SMTP密码:QQ邮箱分配的TOKEN(授权码)
SMTP的SSL类型:TLS
系统邮箱名:postmaster@qq.com

Google Suite邮箱SMTP:

参考:https://support.google.com/a/answer/2956491?hl=zh-Hans

G Suite 免费版并无 SMTP 功能,需要升级到 G Suite 基本版。

参考:https://support.google.com/a/answer/60217
参考:https://support.google.com/a/answer/6389191?hl=zh-Hans
参考:https://www.yuzhiguo.com/631/
参考:https://www.howtoing.com/gmail-smtp-settings

Google邮箱SMTP:

实证未遂。

参考:https://www.cnblogs.com/dragonstreak_1/archive/2010/10/17/1853697.html
参考:https://blog.csdn.net/zdgdq/article/details/78518508
参考:https://www.wpbeginner.com/plugins/how-to-send-email-in-wordpress-using-the-gmail-smtp-server/

https://console.developers.google.com/apis/api/gmail.googleapis.com/credentials
https://developers.google.com/gmail/imap/imap-smtp

The outgoing SMTP server, smtp.gmail.com, requires TLS. Use port 465, or port 587 if your client begins with plain text before issuing the STARTTLS command.

Outgoing Mail (SMTP) Server

smtp.gmail.com

Requires SSL: Yes

Requires TLS: Yes (if available)

Requires Authentication: Yes

Port for SSL: 465

Port for TLS/STARTTLS: 587
Full Name or Display Name Your name
Account Name, User name, or Email address Your full email address
Password Your Gmail password

【方法】

Ping:检查它在哪里?

即使服务器被禁用,所有的服务通常都会对简单的Ping做出响应,所以如果你知道你的DNS是好的,检查服务器是否真的存在:

ping smtp.gmail.com  

返回(按Ctrl + C停止它):

PING gmail-smtp-msa.l.google.com (74.125.133.108): 56 data bytes
64 bytes from 74.125.133.108: icmp_seq=0 ttl=43 time=72.636 ms
64 bytes from 74.125.133.108: icmp_seq=1 ttl=43 time=68.841 ms
64 bytes from 74.125.133.108: icmp_seq=2 ttl=43 time=68.500 ms

telnet:检查它是一个邮件服务器?

可能是某个其他服务正在您尝试连接的SMTP端口上运行。你可以使用这个telnet工具来检查这个(在提交服务端口上连接到gmail):

telnet smtp.gmail.com 587  

返回:

Trying 173.194.67.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
    220 mx.google.com ESMTP ex2sm16805587wjd.30 - gsmtp

如果端口587不起作用,您可以尝试使用端口465或端口25。但端口25通常不支持加密。

如果它没有输出或者没有输出220,那么你的服务器关闭了,或者你的服务器错了。

经过排查,25端口不通,但 587 端口 畅通,果断使用 587 + tls 。

【参考】

参考:https://amon.org/sendmail

参考:https://help.whmcs.com/m/system/l/784309-configuring-whmcs-to-use-smtp
参考:https://newbug.top/whmcs-%e8%a7%a3%e5%86%b3-smtp-%e5%8f%91%e4%bf%a1%e6%9a%b4%e9%9c%b2%e6%9c%8d%e5%8a%a1%e5%99%a8%e6%ba%90ip%e7%9a%84%e6%96%b9%e6%b3%95/
参考:http://www.shuchengxian.com/article/687.html

参考:https://www.fujieace.com/wordpress/smtp-connect-failed.html
参考:https://since1989.org/whmcs/qq-mail-smtp-error-ssl.html
参考:https://www.xxorg.com/archives/717
参考:https://www.xxorg.com/archives/188
参考:http://www.tuxingzhan.com/wpc/3758.html
参考:https://bbs.csdn.net/topics/391894148