Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phpmailer - The following SMTP Error: Data not accepted

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> [email protected]<br />     <b>Message :</b> Here is the message info<br /> '; 

Here is the array of recipients' mails;

$recipients = array("[email protected]","[email protected]"); 

Everything looks fine and email ready to send.Here is the phpmailer config;

$mail = new PHPMailer();  $mail->IsSMTP(); $mail->From = "[email protected]";  $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

like image 247
Yasin Yörük Avatar asked Apr 08 '13 13:04

Yasin Yörük


People also ask

How do I fix SMTP error not accepted?

Solution - Here's How To Resolve ItThe user may need to ensure that the "From" email address matches the SMTP username to resolve this issue. The default parameters may not force this setting; in these cases, the user may need to add the required configuration to force the email address to match the SMTP user name.

Does PHPMailer use SMTP?

PHPMailer can use a non-local mail server (SMTP) if you have authentication. Further advantages include: It can print various kinds of error messages in more than 40 languages when it fails to send an email. It has integrated SMTP protocol support and authentication over SSL and TLS.


2 Answers

your server dosen't allow different sender and username you should config: $mail->From like $mail->Username

like image 168
J Ha Avatar answered Sep 23 '22 07:09

J Ha


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.

like image 22
Jonathan LeRoux Avatar answered Sep 22 '22 07:09

Jonathan LeRoux