php - 在php codeigniter中发送电子邮件到gmail

标签 php email sendmail.exe

我必须向 gamil 发送电子邮件以在我的网站上注册帐户。我正在使用 wamp,win 7,codeigniter。并通过sendmail发送邮件。我已经进行了所有必需的更改,即

在 php.ini 中

; For Win32 only.
SMTP = smtp.gmail.com
smtp_port = 465
; For Win32 only.
;sendmail_from = <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="75180c1018141c19351218141c195b161a18" rel="noreferrer noopener nofollow">[email protected]</a>
sendmail_path ="C:\wamp\sendmail\sendmail.exe -t" 

在sendmail.ini中

smtp_server=smtp.gmail.com
smtp_port=465
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e48591908cbb919781968a858981d9899d8189858d88a48389858d88ca878b89" rel="noreferrer noopener nofollow">[email protected]</a>
auth_password=mypassword

但它显示此错误而不是发送电子邮件。

消息:mail():无法连接到“localhost”端口 25 上的邮件服务器,请验证 php.ini 中的“SMTP”和“smtp_port”设置或使用 ini_set() 文件名:libraries/Email.php

端口 25 上仍然出现错误,但我正在使用端口 465。这可能是什么原因?我做错了什么? 任何帮助。

最佳答案

我认为您必须重新启动服务器。

编辑 我发现this thread解决方案:

Add the following code to the top of your email script if your mail script continues to fail.


// Please specify your Mail Server - Example: mail.yourdomain.com.
ini_set("SMTP","mail.YourDomain.com");

// Please specify an SMTP Number 25 and 8889 are valid SMTP Ports.
ini_set("smtp_port","25");

// Please specify the return address to use
ini_set('sendmail_from', '<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0355626f6a67466e626a6f4260606c766d77435a6c7671476c6e626a6d2d606c6e" rel="noreferrer noopener nofollow">[email protected]</a>');

关于php - 在php codeigniter中发送电子邮件到gmail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16497228/

相关文章:

php - SyncML 与 Android 和 PHP Web 服务

javascript - 电子邮件的手动过滤器。 JavaScript

php - Sendmail Wamp Php

java - 如何使 javax.mail 使用本地 "sendmail"二进制文件?

PHP Sendmail 在 Windows xampp 中失败

javascript - 计算每个 div 的总高度

php - PDO setAttribute 与 PDOException

php - 在 include 中使用字符串作为文件名的一部分

windows - GUI 元素随 MS Outlook 11.0 对象库 + Outlook 2016 Ver 1702 移动

asp.net - 在 ASP.NET 中发送大批量电子邮件的最佳方式是什么?