2017-04-27 100 views
1
  1. 我有这样的代码:Laravel 5.1 - Swift_TransportException - 不能在.ENV文件发送电子邮件

    MAIL_DRIVER = SMTP

    MAIL_HOST=smtp.sendgrid.net 
    
    MAIL_PORT=587 
    
    [email protected] 
    
    MAIL_PASSWORD=hggahsd666 
    
    MAIL_ENCRYPTION=tls 
    

,我得到这个画面:

enter image description here

I也尝试:

MAIL_DRIVER=smtp 
    MAIL_HOST=smtp.sendgrid.net 
    MAIL_PORT=465 
    [email protected] 
    MAIL_PASSWORD=hggahsd666 
    MAIL_ENCRYPTION=ssl 

,但不要再工作......

我也尝试改变设置成配置/ mail.php是一样的.ENV文件,但不工作,并在年底我尝试命令

php artisan cache:clear 

是可能出现的问题的原因重定向到安全域https://asdasd.com/sendEmail

+0

我也尝试用MAIL_ENCRYPTION = NULL却又不工作 –

+0

没有,offcource :) –

+0

的可能的复制[预计响应代码250,但得到的代码“”,与消息“”](http://stackoverflow.com/questions/31133301/expected-response-code-250-but-got-code-with-message) – Nil

回答

1

保持mail.php像这样

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

]; 

然后交叉检查.ENV文件中的所有凭据,如果还是不行,然后去你的电子邮件帐户,并更改应用程序设置,允许不够安全的应用

+0

另请参阅此链接http://stackoverflow.com/questio ns/31133301/expected-response-code-250-but-got-code-with-message ...看起来你的问题重复了。检查这些解决方案,你会得到解决方案。 – Nil