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

醉酒当歌 提交于 2019-12-12 05:29:22

问题


I just developed a laravel web application with mail system. i got error like

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

controller

Mail::send('timesheet/emailtemplate',array('data'=>$query),function($message) 
    {
$message->to('example@gmail.com')->cc('expalecc@gmail.com')->subject('Work Report on - ');
    });

email template file : emailtemplate.blade.php

<h2>hai</h2>

mail.php (config)

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

回答1:


instead of using smtp use Mandrill Driver it is simpler and quicker than use smtp server. by default laravel comes with Mandrill Driver. mandrill required Guzzle 4 HTTP library.. for geting that into your project add

"guzzlehttp/guzzle": "~4.0"

to your composer.json file (in your project root directory)

inside app/config/mail.php

change this line

'driver' => 'mandrill',

go to https://mandrillapp.com/settings
and sign up and generate api key

create an app/config/services.php configuration file if one does not already exist for your project and add below configurations and generated api key

return array(

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

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

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

);

check this out this will be help full Youtube video for setting up Mandrill for laravel



来源:https://stackoverflow.com/questions/28346788/lravel-mail-not-sending-connection-could-not-be-established-with-host-smtp-gm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!