当前位置: 首页 > 知识库问答 >
问题:

Laravel 5.3-SwiftMailer错误:503身份验证优先(#5.5.1)

沈博达
2023-03-14

我正在尝试通过SMTP发送电子邮件(无身份验证)。这是我的。环境设置:

MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=587
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=tls

正如您所见,我的邮件服务器不需要使用tls加密进行身份验证,并且在同一台服务器上,通过PHPMailer(没有Laravel),我可以正确发送电子邮件。事实是,当我尝试通过Laravel发送邮件(使用可邮寄的)时,我收到以下错误:

Swift_TransportException in AbstractSmtpTransport.php line 383:
Expected response code 250 but got code "503", with message "503 AUTH first (#5.5.1)
"

我尝试使用空用户名和密码、ssl加密、不加密、不同端口。。我就是无法通过拉威尔发送电子邮件。

在这里,您可以看到my mailable的构造和构建方法:

public $customerName;
public $customerEmail;
public $emailSubject;
public $emailMessage;


public function __construct($customerName, $customerEmail, $emailSubject, $emailMessage)
    {
        $this->customerName = $customerName;
        $this->customerEmail = $customerEmail;
        $this->emailSubject = $emailSubject;
        $this->emailMessage = $emailMessage;
    }


public function build()
    {
        return $this->view('emails.send');
    }

我错过了什么/做错了什么吗?我似乎找不到解决办法...

提前谢谢大家。


共有1个答案

黄流觞
2023-03-14

您可以发送一封电子邮件而无需身份验证,这是我在config/mail.php中使用的配置,工作正常。

<?php

return [

/*
|--------------------------------------------------------------------------
| Mail Driver
|--------------------------------------------------------------------------
|
| Laravel supports both SMTP and PHP's "mail" function as drivers for the
| sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail.
|
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses",
|            "sparkpost", "log", "array"
|
*/

'driver' => env('MAIL_DRIVER', 'sendmail'),

/*
|--------------------------------------------------------------------------
| SMTP Host Address
|--------------------------------------------------------------------------
|
| Here you may provide the host address of the SMTP server used by your
| applications. A default option is provided that is compatible with
| the Mailgun mail service which will provide reliable deliveries.
|
*/

'host' => env('MAIL_HOST', 'smtp.mailgun.org'),

/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to deliver e-mails to
| users of the application. Like the host we have set this value to
| stay compatible with the Mailgun e-mail application by default.
|
*/

'port' => env('MAIL_PORT', 587),

/*
|--------------------------------------------------------------------------
| Global "From" Address
|--------------------------------------------------------------------------
|
| You may wish for all e-mails sent by your application to be sent from
| the same address. Here, you may specify a name and address that is
| used globally for all e-mails that are sent by your application.
|
*/

'from' => [
    'address' => env('MAIL_FROM_ADDRESS', 'noreply@something.com'),
    'name' => env('MAIL_FROM_NAME', 'Whatever'),
],

/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible default using the
| transport layer security protocol should provide great security.
|
*/

'encryption' => env('MAIL_ENCRYPTION', 'tls'),

/*
|--------------------------------------------------------------------------
| SMTP Server Username
|--------------------------------------------------------------------------
|
| If your SMTP server requires a username for authentication, you should
| set it here. This will get used to authenticate with your server on
| connection. You may also set the "password" value below this one.
|
*/

'username' => env(null),

'password' => env(null),

/*
|--------------------------------------------------------------------------
| Sendmail System Path
|--------------------------------------------------------------------------
|
| When using the "sendmail" driver to send e-mails, we will need to know
| the path to where Sendmail lives on this server. A default path has
| been provided here, which will work well on most of your systems.
|
*/

'sendmail' => '/usr/sbin/sendmail -bs',

/*
|--------------------------------------------------------------------------
| Markdown Mail Settings
|--------------------------------------------------------------------------
|
| If you are using Markdown based email rendering, you may configure your
| theme and component paths here, allowing you to customize the design
| of the emails. Or, you may simply stick with the Laravel defaults!
|
*/

'markdown' => [
    'theme' => 'default',

    'paths' => [
        resource_path('views/vendor/mail'),
    ],
],

];

发送时:

$userArr = array();    
Mail::send('mail.yourviewname', $userArr, function($message) use ($userArr) {
                $message->bcc('someone@something.com', 'Someone');
                $message->to($userArr['email'] ,  $userArr['name'])->subject('Blah blah');
                $message->from('noreply@something.com','Whatever');
            });
 类似资料:
  • cluster=hfactory.getOrCreateCluster(“test cluster”,“localhost:9160”,凭据); 但不幸的是,它给了我一个错误: HFactory类型中的方法getOrCreateCluster(String,CassandraHostConfigurator,Map)不适用于参数(String,String,Map)

  • 问题内容: 我刚刚开始使用docker。我正在按照此处指定的说明进行操作https://docs.docker.com/windows/step_one/ 我在Windows 10和ran上安装了docker(1.10.2)。但是,当本教程未提及任何内容时,出现了身份验证错误。 这是我收到的消息。 我在google&这里搜索,但找不到与此错误消息相似的内容。 谢谢! 问题答案: 当您运行任何其他d

  • 我正在使用Smack4.1原生库为android开发一个聊天应用程序。我可以在应用程序和服务器之间设置连接,但在登录时,我得到了关于SASL身份验证的SmackException。 null null 这是我的logcat输出。 事先谢谢你的帮助。欢呼:)

  • 我想在CDH-5.3.2版本中使用水槽从twitter获取数据。我已经配置了flume.conf、hbase接收器和twitter源代码。 但是,当我启动代理时,我收到以下错误: flume.conf和hbase接收器代码与此博客相同:http://ahikmat.blogspot.com/2014/08/streaming-twitter-tweets-to-hbase-with.html 而且

  • 在controller文件夹中,我有一个名为fbauth.php的控制器,其中有以下代码 但当我点击facebook链接并尝试连接时,我得到了如下错误 另外,为了进行双重检查,我在Kohana之外创建了这个函数,它没有问题。 我所做的是,在Kohana的外部,我创建了一个名为index.php的文件,在其中我输入了html和Facebook身份验证的标记,然后我创建了一个名为testauth.ph

  • 问题内容: 使用Couchbase 5.0及其Java客户端2.0.3时,出现以下错误。 只需按照以下说明打开存储桶即可: https://developer.couchbase.com/documentation/server/current/sdk/java/managing- connections.html 如前所述,使用基本的本地配置,只需两行代码即可: 那应该打开localhost集群