【发布时间】:2016-05-06 20:28:27
【问题描述】:
我正在尝试使用 CodeIgniter 发送电子邮件,这是我的代码
function sendmail()
{
// Set SMTP Configuration
$emailConfig = array(
'protocol' => 'smtp',
'smtp_host' => 'TLS://smtp.googlemail.com',
'smtp_port' => 587,
'smtp_user' => 'email@gmail.com',
'smtp_pass' => '******',
'mailtype' => 'html',
'charset' => 'iso-8859-1'
);
// Set your email information
$from = array('email' => 'frommail@gmail.com', 'name' => 'Your Name');
$to = array('mymail@gmail.com');
$subject = 'Your gmail subject here';
$message = 'Type your gmail message here';
// Load CodeIgniter Email library
$this->load->library('email', $emailConfig);
// Sometimes you have to set the new line character for better result
$this->email->set_newline("rn");
// Set email preferences
$this->email->from($from['email'], $from['name']);
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($message);
// Ready to send email and check whether the email was successfully sent
if (!$this->email->send()) {
// Raise error message
show_error($this->email->print_debugger());
}
else {
// Show success notification or other things here
echo 'Success to send email';
}
}
但它给了我这种类型的错误
遇到以下 SMTP 错误:110 连接超时 无法发送数据:AUTH LOGIN 发送 AUTH LOGIN 命令失败。 错误:无法发送数据:MAIL FROM:
来自:
遇到以下 SMTP 错误:无法发送数据:RCPT 到:
到:
遇到以下 SMTP 错误:无法发送数据:DATA
数据:
遇到以下 SMTP 错误:无法发送数据: 用户代理:CodeIgniter 日期:2016 年 1 月 29 日星期五 06:59:14 +0000 来自: “Alex Tester”返回路径:至:coderjack9@gmail.com 主题: =?iso-8859-1?Q?Email_Test?= 回复:“alextester1003@gmail.com” X-Sender:alextester1003@gmail.com X-Mailer:CodeIgniter X-Priority:3 (正常)消息 ID: Mime 版本:1.0 内容类型:多部分/替代;边界="B_ALT_56ab0dc2af809" 这是 MIME 格式的多部分消息。您的电子邮件应用程序 可能不支持这种格式。 --B_ALT_56ab0dc2af809 内容类型: 文本/纯文本; charset=iso-8859-1 内容传输编码:8 位测试 电子邮件类。 --B_ALT_56ab0dc2af809 内容类型:文本/html; charset=iso-8859-1 内容传输编码:引用打印测试 电子邮件类。 --B_ALT_56ab0dc2af809-- 无法发送数据:.
遇到以下 SMTP 错误:无法使用以下方式发送电子邮件 PHP SMTP。您的服务器可能未配置为使用此功能发送邮件 方法。
【问题讨论】:
标签: php codeigniter email smtp