Question Detail

Why Email going in Spam Folder from Website

5 years ago Views 3358 Visit Post Reply

below is my Send Email Code from Codeigniter : 

$this-> load -> library('email');

    $this-> email -> initialize(array('protocol' => 'smtp', 'smtp_host' => 'mail.serverDomain.com', 'smtp_user' => 'demo@serverDomain.com', 'smtp_pass' => **password**, 'smtp_port' => 26, 'crlf' => "\r\n", 'newline' => "\r\n"));

    $this-> email -> set_mailtype("html");

    $this-> email -> set_newline("\r\n");

    $this-> email -> from("demo@serverDomain.com", "Website Name");

 

 

    $this-> email -> to("demo@gmail.com");
    // change it to yours
    $this-> email -> subject($subject);
    $this-> email -> message($body);

    $this-> email -> send();

It is working fine for sending Mail but Email going in SPAM folder of Gmail.

Please correct me where i am doing wrong?


Thread Reply

Lokesh Gupta

- 5 years ago

$mail = $this->email;
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$mail->initialize($config);
$mail->from('xyz@domain.com', 'Funbook');
$mail->to('someone@domain.com');
$mail->subject('Subject');
$mail->message('Mail testing');
$mail->send();

Anonymous

- 5 years ago

In new Version of CI don't need initialize

Remove 

$this-> email -> initialize(array('protocol' => 'smtp', 'smtp_host' => 'mail.serverDomain.com', 'smtp_user' => 'demo@serverDomain.com', 'smtp_pass' => **password**, 'smtp_port' => 26, 'crlf' => "\r\n", 'newline' => "\r\n"));