我尝试使用带有 codeIgniter 的 gmail 发送电子邮件。这是我的代码:
函数 sendemail($name,$key, $email) {
$this -> load -> library('email');
$econfig['protocol'] = "smtp";
$econfig['smtp_host'] = "ssl://smtp.googlemail.com";
$econfig['smtp_port'] = 465;
$econfig['smtp_user'] = "*******@gmail.com";
$econfig['smtp_pass'] = "******";
$econfig['charset'] = "utf-8";
$econfig['mailtype'] = "html";
$this -> email -> initialize($econfig);
$this->email->set_newline("\r\n");
$this -> email -> from('*********@gmail.com', 'Asoft Administration');
$this -> email -> to($email);
$this -> email -> subject('Subject');
$this -> email -> message("HTML MESSAGE");
if (!$this -> email -> send()) {
echo $this -> email -> print_debugger();
return false;
} else {
return true;
}
}
我的环境是 ubuntu 服务器。我从不使用 postfix 或 sendmail。是否需要发送gmail邮件?我仔细检查了用户名和密码。!
尝试发送电子邮件后,我收到此错误。
您好:250-mx.google.com 随时为您服务,[2607:5300:100:200::377]
250 尺寸 35882577
250-8BITMIME
250-AUTH 登录 PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
250 增强状态代码
第250章
验证密码失败。错误:534-5.7.14 请通过您的网络浏览器登录,然后重试。 534-5.7.14 在 534 5.7.14 了解更多信息
来自:530-5.5.1 需要身份验证。了解更多信息
530 5.5.1
遇到以下 SMTP 错误:530-5.5.1 需要身份验证。了解更多信息,请访问 530 5.5.1 - gsmtp
至:530-5.5.1 需要身份验证。了解更多信息
530 5.5.1
遇到以下 SMTP 错误:530-5.5.1 需要身份验证。在 530 5.5.1 了解更多信息
数据:需要 530-5.5.1 身份验证。了解更多信息
530 5.5.1
遇到以下 SMTP 错误:530-5.5.1 需要身份验证。在 530 5.5.1 了解更多信息
502 5.5.1 命令无法识别。 j4sm48430630qaf.31 - gsmtp
遇到以下 SMTP 错误:502 5.5.1 无法识别的命令。 j4sm48430630qaf.31 - gsmtp
无法使用 PHP SMTP 发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
用户代理:CodeIgniter
日期:2014 年 7 月 3 日星期四 11:20:14 +0200
来自:“Asoft Administration”< ** @gmail.com>
返回路径:< ** @gmail.com>
至: ** @gmail.com
主题:=?utf-8?Q?Qsi_Member_confirmation_mail?=
回复:“ ** @gmail.com” < ** .com>
X 发件人: ** @gmail.com
X-Mailer: CodeIgniter
X 优先级:3(正常)
消息 ID:<53b5204ed3324@gmail.com>
mime 版:1.0
任何人都可以帮助我......非常感谢。
最佳答案
我有同样的问题,这是我的工作代码:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'my@gmail.com',
'smtp_pass' => 'xxx',
'mailtype' => 'html',
'charset' => 'iso-8859-1',
'wordwrap' => TRUE
);
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('my@gmail.com', 'Niraj');
$this->email->to($email);
$this->email->subject('SOME SUBJECT');
$this->email->message('<p>Some Content</p>');
$this->email->send();
关于php - 无法使用 ubuntu 服务器发送谷歌邮件 CodeIgniter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24550673/