2015-02-05 157 views
0

我剛剛開發了一個帶有郵件系統的laravel web應用程序。 我有錯誤,如Lravel郵件不發送 - 無法建立與主機smtp.gmail.com的連接[連接超時#110]

Connection could not be established with host smtp.gmail.com [Connection timed out #110] 

控制器

Mail::send('timesheet/emailtemplate',array('data'=>$query),function($message) 
    { 
$message->to('[email protected]')->cc('[email protected]')->subject('Work Report on - '); 
    }); 

電子郵件模板文件:emailtemplate.blade.php

<h2>hai</h2> 

mail.php(配置)

'driver' => 'smtp', 
'host' => 'smtp.gmail.com', 
'port' => 587, 
'from' => array('address' => null, 'name' => null), 
'encryption' => 'ssl', 
'username' => '[email protected]', 
'password' => 'mypassword', 
'sendmail' => '/usr/sbin/sendmail -bs', 
'pretend' => false, 

回答

0

代替使用smtp使用Mandrill驅動程序它比使用smtp服務器更簡單快捷。默認情況下,laravel附帶Mandrill驅動程序。山魈需要狂飲4 HTTP庫。對於該歌廳到您的項目中添加

"guzzlehttp/guzzle": "~4.0" 

composer.json文件(在你的項目的根目錄)

enter image description here

應用程序/ config/mail.php

更改此行

'driver' => 'mandrill', 

https://mandrillapp.com/settings
和註冊,並生成API密鑰

創建一個應用程序/配置/ services.php配置文件,如果一個不存在的項目,並添加下面的配置和生成的API關鍵

return array(

'mailgun' => array(
    'domain' => '', 
    'secret' => '', 
), 

'mandrill' => array(
    'secret' => 'enter your mandrill api key here', 
), 

'stripe' => array(
    'model' => 'User', 
    'secret' => '', 
), 

); 

檢查了這一點,這將有助於充分 Youtube video for setting up Mandrill for laravel

+0

Thnks很多豬頭... – Jishad 2015-02-06 04:57:38

+0

如何通過mail100.us4.mandrillapp.com **在郵件中刪除** – Jishad 2015-02-06 04:58:35

+0

app/config/mail.php ''from'=> array('address'=>'[email protected]', 'name'=>'webAdmin'),' 改變這一行:) – Alupotha 2015-02-06 05:30:44

相關問題