且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Codeigniter Mail功能将邮件发送到垃圾邮件文件夹

更新时间:2022-12-09 14:18:05

有很多原因发送邮件进入垃圾邮件,但简单的解决方案是在发送邮件之前设置邮件标题并赋予其优先级。该函数是 set_header()

  $ this-> email -> set_header($ header,$ value); 

还请检查此链接供参考。



对我一直有效。


I am using codeigniter mail function. Its sends mail perfectly. But all the time mail going to the spam folder. How can I overcome this.

Function

function msg_now(){
        $this->load->library('email');
        $this->load->library('parser');

        $config['protocol'] = 'sendmail';
        $config['wordwrap'] = TRUE;
        $config['mailtype'] = 'html';
        $this->email->initialize($config);
        $email_id='test@test.com';
        $name=$this->'test';
        $this->email->from('test@gmail.com');
        $this->email->to($email_id);

        $this->email->subject('Test subject');

        $this->email->message("<p>Lorem ipsum dummy content</p>");
        $this->email->send();
}

There are many reasons for mail to go in spam, but easy solution for it is to set the headers of the mail before sending and giving it priority.

Here's how to do that in CodeIgniter. The function is set_header():

$this->email->set_header($header, $value);

also check this link for reference.

It has always worked for me.