简体   繁体   English

PHPMailer - 使用 SMTP Gmail 不接受错误数据

[英]PHPMailer - Error Data not accepted using SMTP Gmail

I am using PHPMailer to send email using SMTP Google but receive following eror But what makes me confuse is this error occured intermitent, sometime the email successfully sent sometime i got this error我正在使用 PHPMailer 使用 SMTP Google 发送电子邮件,但收到以下错误但让我感到困惑的是此错误是间歇性发生的,有时电子邮件成功发送有时我收到此错误

2016-03-11 08:00:50 SMTP ERROR: DATA END command failed: 2016-03-11 08:00:50    SMTP Error: data not accepted. 2016-03-11 08:00:50  CLIENT -> SERVER: QUIT 2016-03-11 08:01:50  SMTP ERROR: QUIT command failed:
phpmailerException Object
(
    [message:protected] => SMTP Error: data not accepted.
    [string:Exception:private] => 
    [code:protected] => 2
    [file:protected] => /home/anekapaperaindah/public_html/application/libraries/PHPMailer/class.phpmailer.php
    [line:protected] => 1492
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => /home/anekapaperaindah/public_html/application/libraries/PHPMailer/class.phpmailer.php
                    [line] => 1300
                    [function] => smtpSend
                    [class] => PHPMailer
                    [type] => ->
                    [args] => Array
                        (

Below is the config for send email以下是发送电子邮件的配置

$destino = $this->input->post('email');
                        $mail = new PHPMailer(true);
                        $mail->Mailer = 'smtp';
                        $mail->SMTPDebug  = 1;
                                    //  $mail->SMTPDebug = true;
                        $mail->IsSMTP(); // we are going to use SMTP
                        $mail->SMTPAuth   = true; // enabled SMTP authentication
                        $mail->SMTPSecure = "ssl";  // prefix for secure protocol to connect to the server
                        $mail->Host = "smtp.gmail.com";     // setting GMail as our SMTP server
                        $mail->Port       = 465;                   // SMTP port to connect to GMail
                        $mail->Username   = 'admin@anekapaperaindah.id';  // user email address
                        $mail->Password   = '********';           // password in GMail
                        $mail->SetFrom($get_email, $company_name);  //Who is sending the email
                        $mail->AddReplyTo($get_email, $company_name);   //email address that receives the response
                        $mail->Subject    = "Reset Password";
                        $mail->SMTPKeepAlive = true;
                        $mail->Priority = 1;
                        $mail->Debugoutput = 'echo';
                        $mail->Timeout = 60;
                        //$mail->SMTPDebug=3;
                        //$mail->Body      = 'tet';;
                        $mail->isHTML(true);  
                        $mail->MsgHTML($msg); 
                        $mail->AddAddress($destino);

Really appeciate for Any suggestion or helps to fix this issue.真的很感谢任何建议或帮助解决这个问题。 Been almost 2 days but still no luck已经快 2 天了,但仍然没有运气

Content of email is HTML format which declared in variable $msg.电子邮件的内容是在变量 $msg 中声明的 HTML 格式。

$msg = $this->load->view('front/notif_reset_password',$data,true);

Below is the html of that view以下是该视图的 html

<table border="0" cellpadding="0" cellspacing="0" width="560" style="background:#ffffff;border:1px solid #cccccc;margin-top:10px" bgcolor="#FFFFFF">
<tbody><tr>
<td align="center" valign="top" style="border-collapse:collapse">

<table border="0" cellpadding="23" cellspacing="0" width="100%" style="background:#ffffff;border-bottom-width:0" bgcolor="#FFFFFF">
<tbody><tr>
<td style="border-collapse:collapse;border-bottom: 3px solid #081071;text-align:center;vertical-align:top" align="left" valign="top">

<img src="http://i650.photobucket.com/albums/uu229/bayu288/logo-aneka_1.png" border="0" alt=" photo logo-aneka.png"/>
<!--<a href="" style="color:#a30046;font-weight:normal;text-decoration:none" target="_blank">
<img alt="Aneka" height="80" src="http://i650.photobucket.com/albums/uu229/images/logo-aneka.png" style="border:0;min-height:auto;line-height:100%;max-width:302px;outline:none;text-decoration:none" width="302" >
</a>-->
</td>

</tr>
</tbody></table>

</td>
</tr>


<tr>
<td align="center" valign="top" style="border-collapse:collapse">

<table border="0" cellpadding="0" cellspacing="0" width="560">
<tbody><tr>
<td valign="top" style="background:#ffffff;border-collapse:collapse" bgcolor="#FFFFFF">

<table border="0" cellpadding="23" cellspacing="0" width="100%">
<tbody><tr>
<td valign="top" style="border-collapse:collapse">
<div style="color:#808080;font-family:Arial;font-size:14px;line-height:150%;text-align:left" align="left">
<div style="color:#808080;font-family:Arial;font-size:14px;line-height:150%;margin:5px 2px;text-align:left" align="left"></div>
<p>Selamat Datang Di PT. Aneka Papera Indah,</p>

<div style="color:#808080;font-family:Arial;font-size:14px;line-height:150%;margin:5px 2px;text-align:left" align="left">


<p><b>Your Detail Information</b></p>
<table style="color:#808080;font-family:Arial;font-size:12px;line-height:150%;text-align:left">

  <tr>
    <td>Email</td>
    <td>:</td>
    <td><?php echo $email ?></td>
  </tr>
  <tr>
    <td>Kode Verifikasi</td>
    <td>:</td>
    <td><?php echo $token_id ?></td>
  </tr>
</table>


<table border="0" cellpadding="5" cellspacing="0" width="100%" style="background:#ffffff;border-collapse:collapse;border:1px solid #cccccc;font-size:12px;margin-bottom:25px" bgcolor="#FFFFFF">

</table>
<table width="100%" style="background:#def0e5;color:#808080;font-family:Arial;font-size:12px;line-height:150%;margin-bottom:40px;text-align:left" bgcolor="#DEF0E5">
<tbody>
<tr>
<td style="border-collapse:collapse;text-align:right;vertical-align:middle" align="right" valign="middle">
<span style="background:#DEF0E5;display:block;min-height:26px;"></span>
</td>
<td style="border-collapse:collapse;vertical-align:middle;text-align: center;" valign="middle">
<p>
<a href="<?php echo base_url().'isms_front_aneka_ctrl/reset_password.html?email='.$email.'&key='.$token_id ?>">Reset Password Anda</a>
</p>
</td>
</tr>
</tbody>
</table>
</div>

<div style="color:#808080;font-family:Arial;font-size:14px;line-height:150%;margin:5px 2px;text-align:left" align="left">
<div style="color:#808080;font-family:Arial;font-size:14px;line-height:150%;text-align:left" align="left">
<br>

Terima kasih atas perhatian dan kepercayaan Anda.
<br>
<br>
<a href="" style="color:#081071;font-weight:normal;text-decoration:none" target="_blank">
<strong>PT Aneka Papera Indah</strong>
</a>
<div style="color:#808080;font-family:Arial;font-size:14px;line-height:150%;text-align:left" align="left">
<div style="color:inherit;font-family:Arial;font-size:14px;line-height:150%;text-align:left;text-decoration:none" align="left">
<?php echo $address ?>
<br>
<?php echo $city ?>
</div>
<span><?php echo $phone ?></span>
-
<span><?php echo $fax ?></span>

</div>
<span>
E-mail :
<a href="mailto:cs@aneka.com" style="color:#a30046;font-weight:normal;text-decoration:underline" target="_blank">cs@anekapaperindah.com</a>
</span>
</div>
<br>

</div>
</div>

</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td align="center" valign="top" style="border-collapse:collapse">

<table border="0" cellpadding="0" cellspacing="0" width="560" style="background:#ffffff;border-top-width:0" bgcolor="#FFFFFF">
<tbody><tr>
<td valign="top" style="border-collapse:collapse">

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td width="23px" style="border-collapse:collapse"></td>
<td valign="middle" style="background:#ffffff;border-collapse:collapse;border:0" bgcolor="#FFFFFF">
<div style="border-top-color:#e8e8e8;border-top-style:solid;border-top-width:1px;color:#707070;font-family:Arial;font-size:10px;line-height:150%;text-align:left" align="left">
&nbsp;
<br>
Follow us
<a href="<?php echo $twitter ?>" style="color:#a30046;font-weight:bold;text-decoration:none" target="_blank">@aneka</a>
&nbsp;
<font color="#CCCCCC"></font>
| &nbsp;Like us on&nbsp;
<a href="<?php echo $facebook ?>" style="color:#a30046;font-weight:bold;text-decoration:none" target="_blank">Facebook.</a>
</div>
<br>
</td>
<td width="23px" style="border-collapse:collapse"></td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
</td>
</tr>



<tr><td><table border="0" cellpadding="10" cellspacing="0" width="560" style="border-collapse:collapse">
<tbody><tr>
<td valign="top" style="border-collapse:collapse">

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody><tr>
<td align="center" valign="middle" style="border-collapse:collapse;color:#999;display:block;font-family:Arial;font-size:10px;font-weight:normal;line-height:130%">
<div>

</div>
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>

</td></tr></tbody></table>

Gmail disables SMTP by default and prefers access through their API. Gmail 默认禁用 SMTP,并且更喜欢通过其 API 进行访问。 You have to enable support for "less secure" applications.您必须启用对“不太安全”的应用程序的支持。 See https://support.google.com/mail/answer/14257?rd=1请参阅https://support.google.com/mail/answer/14257?rd=1

We get this error from PHPMailer when we hit our Gmail send limits .当我们达到Gmail 发送限制时,我们从 PHPMailer 收到此错误。

You can check if it's the same thing happening to you by going into Gmail and trying to manually send an email.您可以通过进入 Gmail 并尝试手动发送电子邮件来检查是否发生了与您相同的事情。 In our case that displays the more helpful error message about sending limits.在我们的例子中,它显示了有关发送限制的更有用的错误消息。

https://support.google.com/a/answer/166852?hl=en https://support.google.com/a/answer/166852?hl=en

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM