Laravel 5.1 - Swift_TransportException - 无法发送电子邮件

时间:2017-04-27 11:59:35

标签: php laravel ssl laravel-5 sendgrid

  1. at .env文件我有这段代码:

    MAIL_DRIVER = SMTP

    Batch API
  2. 我得到这个屏幕:

    enter image description here

    我也试试:

    MAIL_HOST=smtp.sendgrid.net
    
    MAIL_PORT=587
    
    MAIL_USERNAME=azure_edhjjjjj67781b06b18228961b@azure.com
    
    MAIL_PASSWORD=hggahsd666
    
    MAIL_ENCRYPTION=tls
    

    但又不行了......

    我也尝试将设置更改为config / mail.php与.env文件相同但不起作用,最后我尝试命令

    MAIL_DRIVER=smtp
        MAIL_HOST=smtp.sendgrid.net
        MAIL_PORT=465
        MAIL_USERNAME=azure_edhjjjjj67781b06b18228961b@azure.com
        MAIL_PASSWORD=hggahsd666
        MAIL_ENCRYPTION=ssl
    

    可能的问题会导致重定向到安全域https://asdasd.com/sendEmail吗?

1 个答案:

答案 0 :(得分:1)

像这样保留mail.php

<?php
return [
    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 587),
    'from' => [
        'address' => 'hello@example.com',
        'name' => 'Example',
    ],
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME'),
    'password' => env('MAIL_PASSWORD'),
    'sendmail' => '/usr/sbin/sendmail -bs',

];

然后交叉检查.env文件中的所有凭据,如果仍然无效,请转到您的电子邮件帐户并更改应用设置以允许安全性较低的应用