【发布时间】:2016-08-09 12:32:46
【问题描述】:
起初,电子邮件正在发送,但在 cakephp 和 laravel 项目中,电子邮件停止发送。现在,我收到错误:
AbstractSmtpTransport.php 第 383 行中的 Swift_TransportException: 预期响应代码 250,但得到代码“535”,消息“535-5.7.8” 不接受用户名和密码。在 535 5.7.8 了解更多信息 https://support.google.com/mail/answer/14257xn11sm52558396pac.38 - gsmtp"
我删除了两步验证,打开了允许访问不太安全的应用程序的切换按钮,还解锁了验证码等。我尝试了在谷歌上找到的每一步。
public $smtp = array(
'host' => 'ssl://smtp.gmail.com',
'port' => 465,
'username' => 'message@abc.com',
'password' => '123',
'transport' => 'Smtp',
'from' => array('noreply@abc.com' => 'abc'),
'timeout' => 10,
'client' => null,
'log' => true,
'ssl' => true,
'sender' => array('noreply@abc.com')
);
我把虚拟凭据放在这里
<?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", "mail", "sendmail", "mailgun", "mandrill", "log"
|
*/
'driver' => env('MAIL_DRIVER', 'smtp'),
/*
|--------------------------------------------------------------------------
| 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.gmail.com'),
/*
|--------------------------------------------------------------------------
| 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', 465),
/*
|--------------------------------------------------------------------------
| 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' => 'noreply@abc.com', 'name' => 'abc'],
/*
|--------------------------------------------------------------------------
| 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' => 'ssl',
/*
|--------------------------------------------------------------------------
| 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('MAIL_USERNAME', 'message@abc.com'),
/*
|--------------------------------------------------------------------------
| SMTP Server Password
|--------------------------------------------------------------------------
|
| Here you may set the password required by your SMTP server to send out
| messages from your application. This will be given to the server on
| connection so that the application will be able to send messages.
|
*/
'password' => env('MAIL_PASSWORD', 'test'),
/*
|--------------------------------------------------------------------------
| 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',
/*
|--------------------------------------------------------------------------
| Mail "Pretend"
|--------------------------------------------------------------------------
|
| When this option is enabled, e-mail will not actually be sent over the
| web and will instead be written to your application's logs files so
| you may inspect the message. This is great for local development.
|
*/
'pretend' => false,
];
【问题讨论】:
-
能否提供您正在使用的代码和配置?
-
请添加mail.php文件配置。
-
@MinaAbadir,你说的是哪个文件。请告诉我。我是 cakephp 的新手
-
为什么在使用 CakePHP 的同时为 Laravel 标记问题?
-
是的 Gmail 凭据