发送电子邮件提示错误:535身份验证失败

时间:2020-04-22 09:57:37

标签: php codeigniter email

我正在尝试使用CodeIgniter发送电子邮件。当我尝试发送电子邮件时,出现此错误:

Failed to authenticate password. Error: 535 Authentication Failed for no-reply@sample.com
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

我正在使用以下代码:

$config = Array(
        'protocol'    => 'smtp',
        'smtp_host'   => 'smtpout.secureserver.net',
        'smtp_port'   => '465',
        'smtp_user'.  => 'no-reply@sample.com',
        'smtp_pass'   => '0p9o8i7u',
        'smtp_crypto' => 'ssl',
        'mailtype'    => 'html',
        'charset'     => 'iso-8859-1',
        'crlf'        => "\r\n"
);

$this->load->library('email', $config);

$this->email->set_newline("\r\n");
$this->email->from('no-reply@sample.com', 'SYSTEM ROBOT');
$this->email->to('recipient@outlook.com');

$this->email->subject('Sample Subject');
$this->email->message('HTML Content here');

if($this->email->send()){
    return true;
} else {
    return show_error($this->email->print_debugger());
} 

我的项目当前由GoDaddy托管,以及我用来发送电子邮件的电子邮件(此示例为no-reply@sample.com)。

我基于GoDaddy网站上的SMTP设置:https://ph.godaddy.com/help/mail-server-addresses-and-ports-for-business-email-24071

我使用的密码也是正确的,因为我尝试使用 RoundCube 登录电子邮件帐户。

如何解决我遇到的错误?

2 个答案:

答案 0 :(得分:0)

如果上面的代码是真实代码,请尝试使用您的实际帐户更改此部分。

'smtp_user'.  => 'no-reply@sample.com',
'smtp_pass'   => '0p9o8i7u',

因为这 no-reply@sample.com 不是您的真实帐户

答案 1 :(得分:0)

我能够解决我的问题。我没有使用GoDaddy在他们的SMTP settings中建议的内容:

.
.
.
return (
{test.map((orgReport: any) => (  <----seems to break here
  <Card.Body key={orgReport.orgName}>
    {console.log('report: ', orgReport)}
    <Row>
      <Col xs={5} className="padReset">
        <p className="font-weight-bold">Org Name:</p>
      </Col>
.
.
.

首先,转到您的 Web Mail 页面(类似:webmail.yourcpanel.com),然后登录将用于发送电子邮件的电子邮件帐户。

然后转到其他Webmail功能下的配置邮件客户端。您将看到该电子邮件帐户的SSL / TLS设置。就我而言,SMTP主机与GoDaddy的建议不同:

App.tsx

此后,电子邮件现在正在从我的Web应用程序发送。