Search code examples
phpcodeigniteremailspamspam-prevention

Email sent through code going to SPAM folder


I am sending an email to User after who subscribe to my website newsletter. But sometimes the subscription email going to SPAM folder. I am sharing the link of spam mail test result -- https://www.mail-tester.com/web-3339Sp Please check the result(analysis) of SPAM mail tester given above & tell me why my mails are going to SPAM

Here is my configuration to send mail through code-->

    $config = Array( 
'protocol' => 'smtp', 
'smtp_host' => 'mail.holaa.in', 
'smtp_port' => 25, 
'smtp_user' => 'noreply@holaa.in', 
'smtp_pass' => 'XXXXXXXXX', 
'mailtype' => 'html', 
'charset' => 'iso-8859-1' 
); 
$this->load->library('email', $config); 
$this->email->set_newline("\r\n"); 
$this->email->from('noreply@holaa.in'); 
$this->email->to($receiver); 
$this->email->subject($subject); 
$this->email->message($message); 
$ans = $this->email->send();

Thanks in advance


Solution

  • Email server setup:

    The biggest problems are because you are sending it out via a hastily setup mail server.

    1. Delivered to internal network by a host with no rDNS
    2. We check if the server you are sending from is authenticated
    3. You may want to publish a DNS record (A type) for the hostname server18.hosotingraja.in or use a different hostname in your mail software.
    4. Your message is not signed with DKIM

    If you look at the list of issues the priority ones are smtp setup related. If you want I can list a few solutions(specifically to the smtp setup) that might help you with that but they will be dependent upon your isp actioning them; unlikely to happen.

    Quickest solution is to not use that service. For transactional emails there are plenty of services(paid and free) that you can use; Mailgun is a personal favorite because it is api based so removes loads of hassle, a quick google will turn up lots more.

    CodeIgniter email:

    1. Please remove the X_PRIORITY header

    The spam test indicates that your sending out emails with a high priority, it should default to 3 but in this case it apparently is not.

    $this->email->priority(3);
    

    This will set your priority to 'Normal' and reduce your score by 1.56.