2014-02-11 86 views
1

發送電子郵件給codeigniter時遇到問題。發送codeigniter電子郵件時連接超時問題

$config = Array(
'protocol' => 'smtp', 
'smtp_host' => 'ssl://smtp.gmail.com', 
'smtp_port' => 465, 
'smtp_user' => '[email protected]', 
'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('[email protected]', '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(連接超時),電子郵件將不會被用戶接收。我該如何解決這個問題?這是谷歌郵箱的安全問題嗎?

+0

可能重複1555145/sending-email-with-gmail-smtp-with-codeigniter-email-library –

+0

速率限制的可能重複在http://stackoverflow.com/questions/626421/how-can-i-work-with-around中解釋-gmails-smtp -outbound-sending-limits –

+1

我試過可能的重複,我仍然有錯誤。我的代碼在發送單個電子郵件時有效但是當我多次發送它進行測試時,我收到錯誤。請檢查我的問題。謝謝 – Vincent

回答

0

我有類似的問題。首先,檢查垃圾郵件,因爲當我測試我的谷歌時,谷歌決定他們是垃圾郵件,並開始在那裏分類。

我發現,使用該協議向多個用戶發送郵件是非常不可靠的,所以我乾脆跑了循環發送郵件:http://stackoverflow.com/questions/的

function sendEmail($user){ 
    $config = Array(
     'protocol' => 'smtp', 
     'smtp_host' => 'ssl://smtp.gmail.com', 
     'smtp_port' => 465, 
     'smtp_user' => '[email protected]', 
     '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('[email protected]', '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("[email protected]", "[email protected]"); 

foreach($users as $user){ 
    sendMail($user); 
} 
相關問題