【问题标题】:Spam issue in email functionality with SMTP in codeignitercodeigniter 中使用 SMTP 的电子邮件功能中的垃圾邮件问题
【发布时间】:2019-02-20 07:20:42
【问题描述】:

我正在研究电子邮件功能,因为我已经设置了 SMTP,电子邮件适用于 gmail,但是对于电子邮件提供商的邮件将进入垃圾邮件文件夹,任何人都可以帮助我解决这个问题需要做些什么吗?这是我的代码

$config['protocol'] = 'smtp'; 
            $config['smtp_host'] = SMTP_HOST; 
            $config['smtp_user'] = SMTP_USER; 
            $config['smtp_pass'] = SMTP_PASSWORD; 
            $config['smtp_port'] = '587';
            $config['charset'] = 'utf-8';
            $config['wordwrap'] = TRUE;

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

            $this->email->set_header('Content-Type', 'text/html');

            $this->email->from(FROM_EMAIL);
            $this->email->to($email);
            $this->email->set_newline("\r\n");
            $this->email->set_mailtype("html");
            $this->email->subject("Test email");
            $this->email->message("Testing Mail received.");

            if($this->email->send()){
                echo "Email send.";
            } else {
                echo "Error";
            }

【问题讨论】:

  • 您是否使用作为发件人登录到 smtp 服务器的 Gmail 地址(email->from())?如果不是,这可能是导致您的可交付性问题的原因。

标签: codeigniter email codeigniter-3


【解决方案1】:

您好,请尝试这样的 SMTP 设置。 这段代码对我有用。

$mail->IsSMTP();
$mail->SMTPDebug = 2;
$mail->SMPTAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Host = "smtp.gmail.com";
$mail->Mailer = "smtp";
$mail->Port = 587;
$mail->Username = "my@email.com";
$mail->Password = "password";

【讨论】:

  • 我的意思是它在主收件箱文件夹中发送邮件,而不是在垃圾邮件中。
【解决方案2】:

嗨,请试试这个..

            $config['protocol'] = 'smtp';

            $config['smtp_host'] = 'SMTP_USER';

            $config['smtp_port'] = '587';

            $config['smtp_timeout'] = '7';

            $config['smtp_user'] = 'SMTP_USER';

            $config['smtp_pass'] = 'SMTP_PASSWORD';

            $config['charset'] = 'utf-8';

            $config['newline'] = "\r\n";

            $config['mailtype'] = 'html'; // or html

            $config['validation'] = TRUE; // bool whether to validate email or not      

            $this->email->initialize($config);
            $this->email->from('SMTP_USER', 'Name');
            $this->email->to($emailTo);

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



            $this->email->message('message here');


            $this->email->send();

【讨论】:

  • 加载电子邮件库 $this->load->library('email');
【解决方案3】:

试试这个配置

        $config = array(
         'protocol'      => 'SMTP',
         'mailtype'      => 'html',
         'smtp_host'     => '*********',
         'smtp_port'     => '********',
         'charset'       => 'UTF-8',
         'newline'       => "\r\n",
         'auth'          => true, 
         'mailpath'      => '/usr/sbin/sendmail',
         'validate'      => 'FALSE',
       );



        $this->email->clear();
        $this->email->set_newline("\r\n"); 
        $this->email->initialize($config); 
        $this->email->set_mailtype("html");
        $this->email->set_crlf( "\r\n" );
        $this->email->from("*****", "*****");
        $this->email->to($row->email);
        $this->email->subject("******");
        $this->email->message($mesg);

【讨论】:

    猜你喜欢
    • 2013-08-02
    • 1970-01-01
    • 2018-04-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-27
    • 2019-05-31
    • 2014-02-15
    • 1970-01-01
    相关资源
    最近更新 更多