可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I'm trying to figure out this issue for 6 hours. But there is nothing to make sense. Here is the scenario; There is a well formatted HTML
template.
$mail_body = '
<b>Message Num :</b> 769<br />
<b>Message Date :</b> 2013-04-08 09:03:21<br />
<b>Name :</b> John Doe<br />
<b>Phone :</b> 123456789<br />
<b>E-mail :</b> abcdf@somedomain.com<br />
<b>Message :</b> Here is the message info<br />
';
Here is the array of recipients' mails;
$recipients = array("abc@something.com","xyz@somtehing.com");
Everything looks fine and email ready to send.Here is the phpmailer config;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->From = "noreply@something.com";
$mail->FromName = "TEST";
$mail->WordWrap = 50;
foreach($recipients as $mail_add) {
$mail->AddAddress($mail_add);
}
$mail->IsHTML(true);
$mail->Subject = "TEST Subject";
$mail->Body = $mail_body;
if(!$mail->Send()) {
echo $mail->ErrorInfo;
} else {
echo "Mail sent...";
}
Everything is same when I test it. But sometimes email was sent. Sometimes it was not sent. Give me the following error : The following SMTP Error: Data not accepted.
I hope I explained
回答1:
your server dosen't allow different sender and username
you should config: $mail->From
like $mail->Username
回答2:
For AWS users who work with Amazon SES in conjunction with PHPMailer, this error also appears when your "from" mail sender isn't a verified sender.
To add a verified sender:
1.) Log in to your Amazon AWS console: https://console.aws.amazon.com
2.) Select "Amazon SES" from your list of available AWS applications
3.) Select, under "Verified Senders", the "Email Addresses" --> "Verify a new email address"
4.) Navigate to that new sender's email, click the confirmation e-mail's link.
And you're all set.
回答3:
Interestingly, I had the same exact issue and for me the problem was that my connection was timing out. To be able to see more details on my connections, I added $mail->SMTPDebug = 4; to my phpmailer (look up how to capture the debug since the default output function is echo).
Here's the result:
SMTP -> get_lines(): $data was ""
SMTP -> get_lines(): $str is ""
SMTP -> get_lines(): $data is ""
SMTP -> get_lines(): timed-out (10 seconds)
SMTP -> FROM SERVER:
SMTP -> ERROR: DATA not accepted from server:
The default timeout is set to 10 seconds. If your app can support more, add this line to your phpmailer:
$mail->Timeout = 20;
回答4:
Over a certain message of size, it messes up the content when setting through $mail->Body.
You can test it, if it works well with small messages, but doesn't work with larger (over 4-6 kB), then this is the problem.
It seems to be the problem of $mail->Body, so you can get around this by setting the HTML body manually via $mail->MsgHTML($message). And then you can try to only add the non-html body by $mail->AltBody.
Hope that I could help, feel free to provide more details, information.
回答5:
set phpmailer to work in debug to see the "real" error behind the generic message 'SMTP Error: data not accepted' in our case the text in the message was triggering the smtp server spam filter.
$email->SMTPDebug = true;
回答6:
Try to set the port on 26, this has fixed my problem with the message "data not accepted".
回答7:
I was experiencing this same problem. In my instance the send mail was timing out because my Exchange server was relaying email to a server on the internet. That server had exceeded it's bandwidth quota. Apparently php mailer has some built in timeout and it wasn't long enough to see the actual message.
回答8:
We send email via the Gmail SMTP servers, and we get this exact error from PHPMailer sometimes when we hit our Gmail send limits.
You can check if it's the same thing happening to you by going into Gmail and trying to manually send an email. In our case that displays the more helpful error message about sending limits.
https://support.google.com/a/answer/166852?hl=en
回答9:
I was using just
$mail->Body = $message;
and for some sumbited forms the PHP was returning the error:
SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: This message was classified as SPAM and may not be delivered
SMTP code: 550
I got it fixed adding this code after $mail->Body=$message :
$mail->MsgHTML = $message;
$mail->AltBody = $message;