mail(): SMTP server response: 503 This mail server requires authentication when attempting to send to a non-local e-mail address. Please check your mail client settings or contact your administrator to verify that the domain or address is defined for this server.
I am getting this error while I will try to send mail using SMTP. How can I send mail using SMTP in codeigniter?
I am trying this code but getting the error all time and mail can’t be received:
My Code:
<?php mail($r["email"],"Recover your password",$subject,$headers); ?>
Send Email in CodeIgniter With SMTP
Try this example:
<?php $ci = get_instance(); $ci->load->library('email'); $config['protocol'] = "smtp"; $config['smtp_host'] = "ssl://smtp.gmail.com"; $config['smtp_port'] = "465"; $config['smtp_user'] = 'example@gmail.com'; $config['smtp_pass'] = 'Password'; $config['charset'] = "utf-8"; $config['mailtype'] = "html"; $config['newline'] = "rn"; $ci->email->initialize($config); $ci->email->from('support@thedtecherp.com', 'thedtecherp.com'); $list = array($r["email"]); $ci->email->to($list); $ci->email->subject('Recover your password.'); $ci->email->message($subject,$headers); if($ci->email->send()) { $sent=true; }else{ $sent=false; } ?>
Question and answer is powered by AnsPress.io