无法发送AUTH LOGIN命令。错误:无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件

时间:2017-12-26 11:38:53

标签: php codeigniter utf-8 outlook smtp

我正在尝试使用PHP Code-Igniter从Office 365发送电子邮件。 但是我收到了错误:

  

220 MAXPR0101CA0041.outlook.office365.com Microsoft ESMTP MAIL服务   准备在星期二,2017年12月26日11:17:56 +0000

     

你好:250-MAXPR0101CA0041.outlook.office365.com您好[115.96.169.89]

     

250-SIZE 157286400

     

250 PIPELINING

     

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?测试= 20Email?=

     

回复:

     

User-Agent:CodeIgniter

     

X-Sender:myemail@mydomain.com

     

X-Mailer:CodeIgniter

     

X-Priority:3(正常)

     

消息ID:< 5a422fe430795@mydomain.com>

     

Mime-Version:1.0

     

内容类型:multipart / alternative;边界= “B_ALT_5a422fe4307e9”

     

这是MIME格式的多部分邮件。您的电邮申请表   可能不支持这种格式。

     

- B_ALT_5a422fe4307e9内容类型:text / plain; charset = UTF-8 Content-Transfer-Encoding:8bit

     

SMTP发送测试邮件,完成...

     

- B_ALT_5a422fe4307e9 Content-Type:text / html; charset = UTF-8 Content-Transfer-Encoding:quoted-printable

     

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';

欢迎任何形式的帮助,提前谢谢。

1 个答案:

答案 0 :(得分:1)

有类似的问题,我的解决方案正在改变,

$config['protocol'] = "smtp";

为:

$config['protocol'] = "sendmail";
相关问题