电子邮件已发送但未收到

时间:2019-11-11 22:13:25

标签: codeigniter

发送电子邮件的结果为true,但未收到电子邮件。我的配置如下:

$config = Array(
            'protocol' => 'smtp',
            'smtp_host' => 'smtp.gmail.com',
            'smtp_port' => 587,
            'smtp_user' => 'tomaivanovtomov@gmail.com',
            'smtp_password' => 'abc9110033969qwe',
            'mailtype' => 'html',
            'charset' => 'iso-8859-1',
            'smtp_timeout' => 10,
            'smtp_crypto' => 'tls'
        );
        $this->load->library('email', $config);

如果我尝试使用$this->email->initialize($config)$this->load->library('email')之前的其他方法,尝试发送时会出现错误:

fsockopen(): unable to connect to smtp.gmail.com:587 (Connection refused)

3 个答案:

答案 0 :(得分:0)

尝试修改连接以使用ssl代替tls,并使用端口465代替587

'smtp_port' => 465,
'smtp_crypto' => 'ssl'

答案 1 :(得分:0)

使用

更改smtp主机
'smtp_host' => 'ssl://smtp.gmail.com',

检查您的smtp_port并提供正确的端口号

'smtp_port' => 587,

并使用ssl更改加密类型

'smtp_crypto' => 'ssl'

答案 2 :(得分:0)

  • 尝试按以下顺序进行操作。

        $this->load->library('email');
    
        $config['protocol'] = 'smtp';
        $config['smtp_host'] = 'ssl://smtp.googlemail.com';
        $config['smtp_user'] = 'abcdef@gmail.com'; //your email address
        $config['smtp_pass'] = 'testingmails'; // password
        $config['smtp_port'] = 465; 
        $config['smtp_timeout'] = 5;
        $config['wordwrap'] = TRUE;
        $config['wrapchars'] = 76;
        $config['mailtype'] = 'html';
        $config['charset'] = 'utf-8';
        $config['validate'] = FALSE;
        $config['priority'] = 3;
        $config['crlf'] = "\r\n";
        $config['newline'] = "\r\n";
        $config['bcc_batch_mode'] = FALSE;
        $config['bcc_batch_size'] = 200;
    
        $this->email->initialize($config);