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();
}