phpmailer(现在的版本是1.73)是一个很好用的工具,可以很方便的使用php语言发送邮件,支持smtp及验证,我们一直都用它。 但是,由于gmail的smtp采用了ssl连接: Outgoing Mail (SMTP) Server – requires TLS: smtp.gmail.com (use authentication) Use Authentication: Yes Use STARTTLS: Yes (some clients call this SSL) Port: 465 or 587 使用phpmailer就无法正常连接gmail的发信服务器了,并且这个问题一直没有得到phpmailer的官方解决,不过在sf.net上面的讨论里倒是找到了一点资料,采用下面这种方法就可以连接gmail了。 修改class.smtp.php,第101行,把 $this->smtp_conn = fsockopen($host, # the host of the server 改成 $this->smtp_conn = fsockopen(‘ssl://’ . $host, # the host of the server 这样就可以了,就是指定使用ssl协议连接主机,当然php的openssl模块必须打开: extension=php_openssl.dll 但是这样就不能使用非ssl的主机了,我也不像在include目录下面放两份phpmailer,于是,又琢磨出了一种更好的方式: 打开class.phpmailer.php,在大概543行附近,函数SmtpConnect()中,找到: $this->smtp->do_debug … Continue reading 终于能够通过phpmailer使用gmail账号发送邮件了
Copy and paste this URL into your WordPress site to embed
Copy and paste this code into your site to embed