嘿伙计们我正在尝试为我正在开发的这个论坛创建一个重置密码....无论如何我跟着一堆指南并尝试了许多版本的你会看到的,这是一个错误最少的......我仍然无法弄清楚出了什么问题,我可以请你帮忙。
class CI_Email { //in library email.php
var $useragent = "CodeIgniter";
var $mailpath = "/usr/sbin/msmtp"; // Sendmail path
var $protocol = "smtp"; // mail/sendmail/smtp
var $smtp_host = "smtp.googlemail.com"; // SMTP Server.
var $smtp_user = "mymail@gmail.com"; // SMTP Username
var $smtp_pass = "mypass"; // SMTP Password
var $smtp_port = "465"; // SMTP Port
var $smtp_timeout = 5; // SMTP Timeout in seconds
var $smtp_crypto = ""; // SMTP Encryption. Can be null, tls or ssl.
var $mailtype = "html"; // text/html Defines email formatting
var $charset = "utf-8"; // Default char set: iso-8859-1 or us-ascii
这就是结果:
hello: The following SMTP error was encountered: Failed to send AUTH LOGIN command. Error: from: The following SMTP error was encountered: to: The following SMTP error was encountered: data: The following SMTP error was encountered:The following SMTP error was encountered: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method. Content-Type: multipart/alternative; boundary="B_ALT_51cd96f2daf24"
This is a multi-part message in MIME format. Your email application may not support this format.
--B_ALT_51cd96f2daf24 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit
My text here...
--B_ALT_51cd96f2daf24 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
我也在网上找到了很多其他配置,例如:
var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
var $smtp_host = "ssl://smtp.googlemail.com"; // SMTP Server.
或:
var $mailpath = "/usr/sbin/sendmail"; // Sendmail path
var $smtp_host = "ssl://smtp.gmail.com"; // SMTP Server.
使用smtp_host
中的SSL协议,我得到了无数错误的无尽屏幕。
答案 0 :(得分:2)
我使用测试Gmail帐户进行非生产CodeIgniter电子邮件测试,但是当我部署到生产服务器时,我使用ENVIRONMENT
常量来检测正确的邮件连接设置。
对于Gmail,我发现这些配置设置(我放在/application/config/email.php
中)可以正常工作:
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => '<test-account-name>@gmail.com',
'smtp_pass' => '<test-account-password>',
);
您的电子邮件很可能会被收件人的电子邮件标记为垃圾邮件,直到他们将您的发件人列入白名单。
而且FWIW,不要编辑核心CodeIgniter文件,您可以通过多种不同方式提供连接详细信息。