本文介绍了Lravel邮件不发送 - 无法与主机smtp.gmail.com建立连接[连接超时#110]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开发了一个邮件系统的Laravel Web应用程序。
i出现错误,如

 连接无法与主机smtp.gmail.com建立[连接超时#110] 

控制器

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

电子邮件模板文件:emailtemplate.blade.php

 < H2>海< / H2> 

mail.php(config)

 '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,


解决方案

而不是使用smtp使用 Mandrill驱动程序它比使用smtp服务器更简单快捷。默认情况下laravel带有Mandrill驱动程序。 mandrill需要Guzzle 4 HTTP库..进入你的项目添加

 guzzlehttp / guzzle:〜4.0

到您的 composer.json 文件(在您的项目根目录中) p>



里面 app / config / mail.php



更改此行

 'driver'=> 'mandrill',

转到

并注册并生成api密钥



创建一个app / config / services.php配置文件,如果您的项目不存在,并添加以下配置并生成api密钥

  return array(

'mailgun'=>数组(
'domain'=>'',
'secret'=> '',
),

'mandrill'=>数组(
'secret'=>'输入你的mandrill api键这里',


'stripe'=>数组(
'model'=>'User',
'secret'=>'',
),

);

检查这个将会帮助完整


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('[email protected]')->cc('[email protected]')->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' => '[email protected]',
'password' => 'mypassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,
解决方案

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 fullYoutube video for setting up Mandrill for laravel

这篇关于Lravel邮件不发送 - 无法与主机smtp.gmail.com建立连接[连接超时#110]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 18:27