【问题标题】:Lravel Mail not sending -- Connection could not be established with host smtp.gmail.com [Connection timed out #110]Laravel 邮件未发送 - 无法与主机 smtp.gmail.com 建立连接 [连接超时 #110]
【发布时间】:2015-02-05 14:41:38
【问题描述】:

我刚刚开发了一个带有邮件系统的 laravel web 应用程序。 我遇到了类似

的错误
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('example@gmail.com')->cc('expalecc@gmail.com')->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' => 'myemail@example.com',
'password' => 'mypassword',
'sendmail' => '/usr/sbin/sendmail -bs',
'pretend' => false,

【问题讨论】:

    标签: php email laravel-4 gmail


    【解决方案1】:

    使用 Mandrill Driver 而不是使用 smtp,它比使用 smtp 服务器更简单、更快捷。默认情况下,laravel 带有 Mandrill 驱动程序。 mandrill 需要 Guzzle 4 HTTP 库.. 将其添加到您的项目中添加

    "guzzlehttp/guzzle": "~4.0"
    

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

    app/config/mail.php 中

    改变这一行

    'driver' => 'mandrill',
    

    转到https://mandrillapp.com/settings
    并注册并生成 api 密钥

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

    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

    【讨论】:

    • 还有如何在邮件中删除 via mail100.us4.mandrillapp.com
    • app/config/mail.php 'from' =&gt; array('address' =&gt; 'whatever@gmail.com', 'name' =&gt; 'webAdmin'), 更改此行:)
    • 我已经在 mail.php 中设置了它,但我收到它显示。 Naveen demo@test.com via mail100.us4.mandrillapp.com
    • ohh sending-domains how to set sending-domains 我不知道它在 localhost 上是如何工作的 :(
    • 这个答案现在已经过时了,因为 mandrill 是 MailChimp 的付费插件。
    猜你喜欢
    • 2017-01-18
    • 2017-10-15
    • 2018-12-29
    • 2017-05-01
    • 2018-12-30
    • 2011-02-13
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    相关资源
    最近更新 更多