-1

This was working on my live server before then suddenly it's no longer sending emails. Here's the error I got:

220 smtp30.relay.iad3a.emailsrvr.com ESMTP - VA Code Section 18.2-152.3:1 forbids use of this system for unsolicited bulk electronic mail (Spam) hello: 250-smtp30.relay.iad3a.emailsrvr.com 250 ENHANCEDSTATUSCODES Failed to send AUTH LOGIN command. Error: 554 5.7.1 authentication restricted (Z1E/233FC14) from: 554 5.7.1 authentication restricted (Z1E/233FC14) The following SMTP error was encountered: 554 5.7.1 authentication restricted (Z1E/233FC14) to: 503 5.5.1 Bad sequence of commands The following SMTP error was encountered: 503 5.5.1 Bad sequence of commands data: 503 5.5.1 Bad sequence of commands The following SMTP error was encountered: 503 5.5.1 Bad sequence of commands 221 2.7.0 Error: I can break rules, too. Goodbye. The following SMTP error was encountered: 221 2.7.0 Error: I can break rules, too. Goodbye. Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

If I run it on my local server it's sending emails. I even tried changing the ports to 587 and I still got error and it's not sending. What would be the issue in my code. Thank you!

Here's my code:

$from = "no-reply@sample.com";
$from_name = "Daily logs";

$config['smtp_host']    = 'ssl://secure.sample.com';
$config['smtp_user']    = 'no-reply@sample.com';
$config['smtp_pass']    = ********;
$config['smtp_port']    = '465';

$config['protocol']     = 'smtp';

$config['mailtype']     = 'html';
$config['validate']     = 'FALSE';
$message                = $email_message['html'];


$CI->email->initialize($config);
$CI->email->from($from, $from_name);
$CI->email->to($email_message['to']);
$CI->email->subject("Sample - ".$email_message['subject']);

$path=$_SERVER["DOCUMENT_ROOT"];
$file = $path.'/tmp/sample_data/sample_data_'.strtotime(date("y-m-d", strtotime('-1 day'))).'.csv';
$CI->email->attach($file);

$CI->email->message($message);
if(@$CI->email->send()){
     $return = (object) array('http_response_code' => 200); 
}
else{
     echo $CI->email->print_debugger();
}
M. Eriksson
  • 13,450
  • 4
  • 29
  • 40
irish
  • 39
  • 2
  • 8
  • unsolicited bulk spam? check your email for your domain is set up correctly by visiting here https://toolbox.googleapps.com/apps/checkmx/ – delboy1978uk Sep 19 '18 at 12:02
  • how would that help? – irish Sep 19 '18 at 12:12
  • _"ESMTP - VA Code Section 18.2-152.3:1 forbids use of this system for unsolicited bulk electronic mail (Spam)"_ - It sounds like your SMTP-host have blocked you from sending more spam emails. Contact them. There's nothing we can do about it. – M. Eriksson Sep 19 '18 at 12:20
  • if dkim or spf records or whatever aren't set up correctly (and that site will tell you) then yes, many email servers will auto reject you because it looks suspicious – delboy1978uk Sep 19 '18 at 13:44

1 Answers1

1

check if your configuration is write

$config['smtp_host']    = 'ssl://secure.sample.com';
$config['smtp_user']    = 'no-reply@sample.com';
$config['smtp_pass']    = ********;

I think you can try those points by gmail and then move to your own configuration just for testing your code is fine. some times the server might not allow you so don't wast time. links for gmail smtp Send email using the GMail SMTP server from a PHP page and Sending email with gmail smtp with codeigniter email library

Sinte
  • 91
  • 1
  • 10
  • I tried the gmail smtp it works on my personal email by turning on the less secure apps but when I try to use another account it says failed to authenticate password. My password is correct I even tried to login via browser and I already turn on the less secure apps. Do I have to turn on or off something in google settings? Thanks – irish Sep 20 '18 at 03:07
  • - Enable IMAP and assert the right maximum number of messages. - Make sure your password is at least 7 characters and is strong (according to Google) - Make sure you don't have to enter a captcha code first. You can do so by sending a test email from your browser. – Sinte Sep 27 '18 at 15:39