错误:无法发送AUTH LOGIN命令。错误: 无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。
这是我的电子邮件功能
public function sendMail($emails) {
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.office365.com',
'smtp_user' => 'no-reply@casrilanka.org',
'smtp_pass' => 'my_password',
'smtp_port' => '587',
'smtp_crypto' => 'TLS'
);
$ip = $this->input->ip_address();
$message = 'dsfsdfsdgndsgjdfgdsfjgkdfgkjdfghdfkghdfsbsdfgjklg';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('keesampath@gmail.com'); // change it to yours
$this->email->to('sampathw.pipl@gmail.com'); // change it to yours
$this->email->subject('Application submission');
$this->email->message($message);
$sss = $this->email->send();
if($sss){
echo 'ok';
}else{
echo $this->email->print_debugger();
exit;
}
}
结果:
220 KL1PR0601CA0020.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 23 Jun 2017 10:17:09 +0000
hello: 250-KL1PR0601CA0020.outlook.office365.com Hello [52.221.154.133]
250-SIZE 157286400
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-8BITMIME
250-BINARYMIME
250 CHUNKING
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.
User-Agent: CodeIgniter
Date: Fri, 23 Jun 2017 10:17:09 +0000
From: <keesampath@gmail.com>
Return-Path: <keesampath@gmail.com>
To: sampathw.pipl@gmail.com
Subject: =?UTF-8?Q?Application=20submissi?==?UTF-8?Q?on?=
Reply-To: <keesampath@gmail.com>
X-Sender: keesampath@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <594ceaa560fb1@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
我的代码中会出现什么问题。谢谢!