0

I am sending mail using codeigniter, When I send a mail to my Company id

shahjada@ocodewire.com then the message is going to the inbox folder But When I

Send the mail to the my gmail_id shahjad.ahmadtimt@gmail.com then mail go to

The Spam Folder.I don't know where is a Problem.

Code here

public function sendMail($message, $adminEmail,$emailData) {

    /*print_r($message);
    print_r($adminEmail);
    print_r ($emailData);die;
    */
    $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => 'shahjad.ahmadtimt@gmail.com', 
        'smtp_pass' => 'password',
        'mailtype' => 'html',
        'charset' => 'iso-8859-1',
        'wordwrap' => TRUE
    ); 

    $this->load->library('email', $config);            
    $this->email->from($adminEmail);
    $this->email->to($emailData);
    $this->email->subject('hi thanks.');
    $this->email->message($message);

    if($this->email->send())
    {
        echo 'Email sent.';
    }
    else
    {
        show_error($this->email->print_debugger());
    }        
}
Shahzad Ditro
  • 129
  • 1
  • 16
  • Try using an SMTP service like MainGun - https://www.mailgun.com/ – Tom Apr 05 '16 at 12:56
  • use answer told by fred-ii http://stackoverflow.com/questions/18229279/sending-email-via-php-mail-function-goes-to-spam – Linus Apr 05 '16 at 15:07

1 Answers1

0

In Gmail, find one of the messages and click the little arrow next to the reply icon at the top right. Click 'Show Original'. Search on the page for Received-SPF:. If it says fail or softfail, you need to look into setting SPF DNS records up properly for your domain. Your web host may be able to do this for you. These records will let Gmail (and other junk filters) know that your server is allowed to send email from your domain. If it says Received-SPF: pass then there must be a different problem at play.

Josh Harrison
  • 5,927
  • 1
  • 30
  • 44
  • Where, I can search for SPF – Shahzad Ditro Apr 05 '16 at 12:31
  • Try [this search](https://www.google.com/?q=email+spf#safe=active&q=email+spf). I'd advise you speak with whoever manages your domain name, as they may be able to do it for you. It's a change to your domain's DNS records. – Josh Harrison Apr 05 '16 at 13:27