Php Laravel默认邮件不工作
我正在尝试在注册时发送用户激活电子邮件。我有一个简单的laravel注册和认证网站。注册后,没有错误,数据存储正确,但电子邮件从未实际发送。尝试了几个不同的例子,但我有同样的问题 这是我的mail.php配置文件-Php Laravel默认邮件不工作,php,email,laravel,smtp,Php,Email,Laravel,Smtp,我正在尝试在注册时发送用户激活电子邮件。我有一个简单的laravel注册和认证网站。注册后,没有错误,数据存储正确,但电子邮件从未实际发送。尝试了几个不同的例子,但我有同样的问题 这是我的mail.php配置文件- <?php return array( /* |-------------------------------------------------------------------------- | Mail Driver |-------
<?php
return array(
/*
|--------------------------------------------------------------------------
| 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"
|
*/
'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 Postmark mail service, which will provide reliable delivery.
|
*/
'host' => 'smtp.mailgun.org',
/*
|--------------------------------------------------------------------------
| SMTP Host Port
|--------------------------------------------------------------------------
|
| This is the SMTP port used by your application to delivery e-mails to
| users of your application. Like the host we have set this value to
| stay compatible with the Postmark e-mail application by default.
|
*/
'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' => array('address' => 'admin@klinkon.com', 'name' => 'God'),
/*
|--------------------------------------------------------------------------
| 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' => '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' => null,
/*
|--------------------------------------------------------------------------
| 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' => 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',
/*
|--------------------------------------------------------------------------
| 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,
);
尝试通过将tls加密设置为
'encryption' => '',
我有一个类似的问题,tls就是它。好吧,我会给你一个“放弃一个”
,但我的声誉不够高(好像坏了)。我和我的ISP在连接到他们的smtp服务器时遇到了完全相同的问题。通过使用laravel,我最终获得电子邮件的唯一方法是将“加密”值设置为nothing(即与上面的帖子一样)。端口更改、帐户更改等的每一次组合都会导致laravel异常。我尝试使用我的gmail帐户和凭据,但没有成功
最后唯一有效的设置组合是使用
'host' => 'smtp.your-domain',
'port' => 587,
'encryption' => '',
'username' => 'Your-account@Your-domain',
'password' => 'your-password for Your-account',...
扩展上面的答案,因为它们不适合我 您定义的端口必须与正确的加密类型相关联。事实证明,ssl和tls并不等同,它们与不同的端口相互关联。
laravel中的默认加密设置是在tls(端口587)上设置的,但是如果您使用的是端口465,则需要将其更改为ssl 谷歌的smtp.gmail.com服务器就是一个很好的例子:
'host' => 'smtp.gmail.com',
'port' => 465,
'encryption' => 'ssl',
或
此外,端口587不强制使用加密()。如果您发现设置'encryption'=>''
对您有效,则应发出红旗,因为这可能意味着您使用的smtp服务器未加密您的电子邮件。在这种情况下,如果您在使用Xampp的本地计算机上使用它,您应该找到其他发送电子邮件的方法。。请禁用在后端运行的所有加密应用程序。我也遇到过同样的问题,当我禁用PGP加密软件时,问题得到了解决。加密软件不允许向电子邮件传递令牌 Config/mail.php
我有这个问题,但我在.env文件中设置了配置邮件,并使用了以下方法:
php artisan config:cache
泰,伙计,只要它能解决问题,就不需要升级。不过,提一下泰:)谢谢。但也要设置'driver'=>'smtp'。一个从我开始的“没有价值”的东西。救命恩人!这也是我的问题-我在.env中设置了MAIL_ENCRYPTION='',因为我只想不在本地开发环境中使用TLS,在那里我使用papercut捕获出站电子邮件。我在Laravel 5.5上,mail.php现在有一行“encryption”=>env('mail_encryption','tls'),
'host' => 'smtp.gmail.com',
'port' => 587,
'encryption' => 'tls',
<?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' => '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' => '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' => 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' => 'your mail', 'name' => 'Project'],
/*
|--------------------------------------------------------------------------
| 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' => '',
/*
|--------------------------------------------------------------------------
| 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' => 'your email (gmail)',
/*
|--------------------------------------------------------------------------
| 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' => 'password (email)',
/*
|--------------------------------------------------------------------------
| 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,
];
use Illuminate\Contracts\Mail\Mailer;
$message = [
'title' => 'Verification code',
'intro' => "Please verify your email address with ".$user->confirmation_code,
'link' => '',
'confirmation_code' => '',
'to_email' => $user->email,
'to_name' => $user_details->first_name.' '.$user_details->last_name,
];
\Mail::send('emails.auth.verify', $message, function($m) use($message) {
$m->to($message['to_email'], $message['to_name'])
->subject('Email verification');
});
php artisan config:cache