繁体   English   中英

发送电子邮件给codeigniter时出现连接超时问题

[英]connection time out issue when sending email for codeigniter

将电子邮件发送到codeigniter时出现问题。

    $config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.gmail.com',
'smtp_port' => 465,
'smtp_user' => 'email@gmail.com',
'smtp_pass' => 'xxxxx',
'mailtype'  => 'html', 
 'charset'   => 'iso-8859-1'

);

$this->load->library('email', $config);
$this->email->set_newline("\r\n");
$this->email->to($user['company_email']);
$this->email->from('noreply@email.com', 'COMPANY');   
$this->email->subject('Password reset');
$this->email->message('You have requested a code. Here is your code: '. $reset['return_pass']);  
    $this->email->send();

有时,我可以毫无问题地发送电子邮件,但是如果我多次使用它或多个用户使用此发送电子邮件(用于忘记密码),则googlemail无法连接到ssl://smtp.googlemail.com:465(连接超时),用户将不会收到该电子邮件。 如何解决此问题? 这是googlemail的安全问题吗?

我有一个类似的问题。 首先,检查垃圾邮件,因为在我测试我的垃圾邮件时,Google判定它们为垃圾邮件,并开始在其中进行分类。

我发现使用此协议向多个用户发送邮件非常不可靠,因此我只运行了一个循环来发送邮件:

function sendEmail($user){
     $config = Array(
        'protocol' => 'smtp',
        'smtp_host' => 'ssl://smtp.gmail.com',
        'smtp_port' => 465,
        'smtp_user' => 'email@gmail.com',
        'smtp_pass' => 'xxxxx',
        'mailtype'  => 'html', 
        'charset'   => 'iso-8859-1'
     );

    $this->load->library('email', $config);
    $this->email->set_newline("\r\n");
    $this->email->to($user);
    $this->email->from('noreply@email.com', 'COMPANY');   
    $this->email->subject('Password reset');
    $this->email->message('You have requested a code. Here is your code: '.
    $reset['return_pass']);  
    $this->email->send();
}


$users = array("person1@test.com", "person2@test.com");

foreach($users as $user){
    sendMail($user);
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM