【问题标题】:Email with laravel SMTP of Godaddy account fails?使用 Godaddy 帐户的 laravel SMTP 发送电子邮件失败?
【发布时间】:2016-09-16 15:50:40
【问题描述】:

我正在尝试使用 godaddy 帐户在 laravel 中发送电子邮件,但我总是收到错误

AbstractSmtpTransport.php 第 383 行中的 Swift_TransportException: 预期响应代码 250,但得到代码“501”,消息“501 HELO 需要有效地址”

以下代码用于在控制器中发送电子邮件:

$title = 'Test email';
$content = 'Test email from shingora';

Mail::send('emails.send', ['title' => $title, 'content' => $content], function ($message) {

    $message->from('robin.shingora@gmail.com', 'Shingora');
    $message->subject('Test email');

    $message->to('robin.shingora@gmail.com');
});

在mail.php中

return [
'driver' => 'smtp',
'host' => 'smtpout.asia.secureserver.net',
'port' => 25,
'from' => ['address' => 'example@gmail.com', 'name' => 'test'],
'encryption' => 'ssl',
'username' => 'example@gmail.com',
'password' => '********',
'sendmail' => 'D:\sendmail\sendmail -bs',
'pretend' => false,
];

【问题讨论】:

    标签: laravel email


    【解决方案1】:

    在您的 .env 文件中设置所有 smtp 设置 即

    MAIL_DRIVER=smtp
    MAIL_HOST=ssl://smtp.gmail.com
    MAIL_PORT=465
    MAIL_USERNAME=example@gmail.com
    MAIL_PASSWORD=*******
    MAIL_ENCRYPTION=null
    

    return [
    
    'driver' => 'smtp',
    
    'host' => 'ssl://smtp.gmail.com',
    
    'port' => 465,
    
    'from' => ['address' => 'example@gmail.com', 'name' => 'test'],
    
    'encryption' => 'ssl',
    
    'username' => 'example@gmail.com',
    
    'password' => '********',
    
    'sendmail' => 'D:\sendmail\sendmail -bs',
    
     'pretend' => false,
    ];
    

    【讨论】:

      【解决方案2】:

      几周前我遇到了同样的问题,我意识到 GoDaddy 喜欢让您的发件人和回复电子邮件属于您自己的域,从而解决了这个问题。

      这可能是您的主机名有问题,所以我浏览了另一个 SO 问题并发现了这个:

      Configure SwiftMailer "Local Domain" setting easily, in Symfony 2

      【讨论】:

      • 有同样的问题,但在我的情况下,发件人电子邮件(来自电子邮件)属于自己的域。请提出一些解决方案。
      猜你喜欢
      • 1970-01-01
      • 2016-02-14
      • 2017-02-09
      • 1970-01-01
      • 2017-02-11
      • 2013-10-15
      • 2018-08-19
      • 2021-05-06
      • 2015-06-23
      相关资源
      最近更新 更多