0

我使用此代码发送测试电子邮件,但我总是遇到错误,我该怎么办?

//==========code======================

$config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'localhost',
        'smtp_port' => 25,

        'smtp_user' => 'root',

        'smtp_pass' => '', 

        'mailtype' => 'html',

        'charset' => 'iso-8859-1',
        'wordwrap' => TRUE
);

$message = ' hello world';
$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->from('xxxxx@live.com'); 
$this->email->to('xxxxx@live.com');
$this->email->subject('Resume from JobsBuddy for your Job posting');
$this->email->message($message);
if($this->email->send())
{
        echo 'Email sent.';
}
else
{
        show_error($this->email->print_debugger());
}

来自 CodeIgniter 的错误:

 An Error Was Encountered


    The following SMTP error was encountered: 10061 No connection could be made because 

    the target machine actively refused it. 




    Unable to send data: AUTH LOGIN
    Failed to send AUTH LOGIN command. Error: 


    Unable to send data: MAIL FROM:


    from: 
    The following SMTP error was encountered: 
    Unable to send data: RCPT TO:
    to: 
    The following SMTP error was encountered: 
    Unable to send data: DATA
    data: 
    The following SMTP error was encountered: 
    Unable to send data: User-Agent: CodeIgniter Date: Wed, 6 Nov 2013 13:50:31 +0000 From: Return-Path: To: xxxx@live.com Subject: =?iso-8859-1?Q?Resume_from_JobsBuddy_for_your_Job_posting?= Reply-To: "xxxx@live.com" X-Sender: 


xxx@live.com X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: 


<527a492796d84@live.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_527a492796d84" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_527a492796d84 Content-Type: text/plain; 


charset=iso-8859-1 Content-Transfer-Encoding: 8bit hello world --B_ALT_527a492796d84 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable hello world --B_ALT_527a492796d84--
        Unable to send data: .

        The following SMTP error was encountered: 
        Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

    User-Agent: CodeIgniter


    Date: Wed, 6 Nov 2013 13:50:31 +0000
    From: 


    Return-Path: 
    To: xxx@live.com


    Subject: =?iso-8859-1?Q?Resume_from_JobsBuddy_for_your_Job_posting?=
    Reply-To: "xxx@live.com" 
    X-Sender: xxx@live.com
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: <527a492796d84@live.com>
    Mime-Version: 1.0


    Content-Type: multipart/alternative; boundary="B_ALT_527a492796d84"

    This is a multi-part message in MIME format.
    Your email application may not support this format.



    --B_ALT_527a492796d84


    Content-Type: text/plain; charset=iso-8859-1


    Content-Transfer-Encoding: 8bit

    hello world


    --B_ALT_527a492796d84
    Content-Type: text/html; charset=iso-8859-1


    Content-Transfer-Encoding: quoted-printable

     hello world

    --B_ALT_527a492796d84--
4

3 回答 3

2

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

  1. 确保 SMPT 参数正确
  2. 确保您的服务器正在运行 SMTP 服务
于 2013-11-06T14:21:25.643 回答
0

您的问题是您的服务器不允许root用户登录到 SMTP 服务器(永远不要使用 root 作为您的用户)。

查看本教程,了解如何设置 SMTP,或者使用Amazon SESGMail等其他提供商发送电子邮件。这将增加您的邮件不会被标记为垃圾邮件的几率。

于 2013-11-06T14:21:05.657 回答
-2
Unable to send data: AUTH LOGIN
Failed to send AUTH LOGIN command. Error: Unable to send email using PHP SMTP.

您的服务器可能未配置为使用此方法发送邮件。

1.确保SMPT参数正确

2.确保您的服务器有 SMTP 服务正在运行

于 2015-08-05T14:35:00.907 回答