![](/img/trans.png)
[英]Codeigniter 3 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method
[英]Failed to send AUTH LOGIN command. Error: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method
我正在尝试使用PHP Code-Igniter从Office 365发送电子邮件。 但我得到一个错误:
220 MAXPR0101CA0041.outlook.office365.com Microsoft ESMTP邮件服务已准备在2017年12月26日星期二11:17:56 +0000
您好:250-MAXPR0101CA0041.outlook.office365.com您好[115.96.169.89]
250尺寸157286400
250流水
250-DSN
250 ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250 BINARYMIME
250-CHUNKING
250 SMTPUTF8
无法发送AUTH LOGIN命令。 错误:504 5.7.4无法识别的身份验证类型[MAXPR0101CA0041.INDPRD01.PROD.OUTLOOK.COM]
无法使用PHP SMTP发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件。
日期:2017年12月26日,星期二12:17:56 +0100
从:
返回路径:
至:myemail@mydomain.com
主题:=?UTF-8?Q?Test = 20Email?=
回复:
用户代理:CodeIgniter
X寄件者:myemail@mydomain.com
X-Mailer:CodeIgniter
X优先级:3(普通)
邮件ID:<5a422fe430795@mydomain.com>
Mime版本:1.0
内容类型:多部分/替代; 边界= “B_ALT_5a422fe4307e9”
这是MIME格式的多部分消息。 您的电子邮件应用程序可能不支持此格式。
--B_ALT_5a422fe4307e9内容类型:文本/纯文本; charset = UTF-8内容传输编码:8位
SMTP发送测试电子邮件,完成...
--B_ALT_5a422fe4307e9内容类型:text / html; charset = UTF-8内容传输编码:带引号的可打印
SMTP发送测试电子邮件,完成...
--B_ALT_5a422fe4307e9--
这是我的控制器代码:
public function emailSend()
{
# code...
/*
Minimun test code for successful email sending over SMTP with Office 365
Things to double-check:
- openssl php extension must be enabled in the server
- host set to smtp.office365.com, not the old aliases
- Port 587
- newline configuration: explicit to "\r\n"
*/
//In your Controller code:
$this->load->library('email');
//$config = [
$config['protocol']= 'smtp';
$config['mailpath']= "/usr/lib/sendmail";
$config['smtp_port']= 587;
$config['smtp_timeout'] = '7';
$config['smtp_host']= 'smtp-mail.outlook.com';
$config['smtp_user']= 'myemail@mydomain.com';
$config['smtp_pass']= '*********';
$config['smtp_crypto']= 'STARTTLS';
$config['newline']= "\r\n"; //REQUIRED! Notice the double quotes!
$config['crlf']= "\r\n";
$config['mailtype'] = 'html';
//];
$this->email->initialize($config);
$this->email->from('myemail@mydomain.com');
$this->email->to('myemail@mydomain.com');
$this->email->subject('Test Email');
$this->email->message('SMTP sending test email, Done...');
$sent = $this->email->send();
if ($sent)
{
echo 'OK';
} else {
echo $this->email->print_debugger();
}
}
我检查了很多链接和问题,但没有成功。 我没有得到什么是代码中的确切错误。
注意:我尝试过
$config['smtp_port']= 465;
$config['smtp_crypto']= 'TLS';
$config['smtp_crypto']= 'SSL';
谢谢您的任何帮助。
有类似的问题,我的解决方案正在改变,
$config['protocol'] = "smtp";
至:
$config['protocol'] = "sendmail";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.