【问题标题】:How to get the response of bounced mail when working with google mail smtp (smtp.googlemail.com)使用 google mail smtp (smtp.googlemail.com) 时如何获得退回邮件的响应
【发布时间】:2018-01-02 17:34:07
【问题描述】:

我正在制作时事通讯。我有大量 1200 封电子邮件,但未经过验证。我在 codeigniter 框架中使用 google 邮件 smtp 进行验证。邮件正在正确发送,但是当我测试它是否有错误的电子邮件时,它也会显示发送邮件状态。我想问一下在使用谷歌邮件 smtp 时如何获得退回邮件的响应。

$check 包含电子邮件数组:

 $config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.googlemail.com',
            'smtp_port' => '465',
            'smtp_user' => 'mymail@gmail.com',
            'smtp_pass' => 'mypass',
            'mailtype'  => 'html', 
            'charset'   => 'iso-8859-1',
            'send_multipart' => FALSE
        );
        $this->email->initialize($config);  
        $this->load->library('email', $config);

        foreach($_POST['chk'] as $check) 
        {
                    $this->email->clear();
                    $data = array(
                     'userName'=> 'Myname'
                         );
                   $this->email->set_newline("\r\n");   
                   $this->load->library('email',$config);




                   $this->email->from("mymail@gmail.com","Myname");

                    //echo $row->email;
                    $this->email->to($check);
                    $this->email->subject("THIS IS AN EMAIL TEST");
                    $gett = $this->load->view('home_test.php',$data,TRUE);
                    $this->email->message($gett);  
                    $this->email->set_mailtype("html");
                    if($this->email->send())
                    {
                        echo "Your Mail send";
                    }
                    else
                    {
                        show_error($this->email->print_debugger());
                        exit();
                    }
        }

尽管我提供了虚假的电子邮件 ID,但它始终显示您的邮件发送。如何在 PHP 中跟踪此退回的邮件。

【问题讨论】:

    标签: php codeigniter email smtp


    【解决方案1】:

    您不会在发送后立即获得退回电子邮件的状态。您可以做的是,将返回路径电子邮件指定为$this->email->from("mymail@gmail.com","Myname"); 的第三个参数。

    改变这一行

    $this->email->from("mymail@gmail.com","Myname");

    $this->email->from("mymail@gmail.com","Myname", 'yourreturnemail@gmail.com');

    有关更多详细信息,请参阅 codigniter 的电子邮件文档here

    这样所有退回的电子邮件都会到达返回路径的电子邮件地址。然后你可以创建一个 cron 或其他东西来阅读和解析这些电子邮件。 php 的imap extension 可以安装并用于阅读电子邮件退回状态。

    【讨论】:

      猜你喜欢
      • 2018-03-17
      • 2013-05-15
      • 2020-11-04
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-21
      • 1970-01-01
      相关资源
      最近更新 更多