有没有办法使用自定义的电子邮件地址发送电子邮件。例如,我有一个域名(www.laracast.com)和一个定制的电子邮件(noreply@laracast.com)。
如何从noreply@laracast.com向我的用户发送电子邮件
我在env中有这个
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=xxxxxxxxxxxxx
MAIL_PASSWORD=xxxxxxxxxxxx
MAIL_ENCRYPTION=null
和我的config / mail.php
return [
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.mailgun.org'),
'port' => env('MAIL_PORT', 587),
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'noreply@pconnect.com'),
'name' => env('MAIL_FROM_NAME', 'PConnect'),
],
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME'),
'password' => env('MAIL_PASSWORD'),
'sendmail' => '/usr/sbin/sendmail -bs',
'markdown' => [
'theme' => 'default',
'paths' => [
resource_path('views/vendor/mail'),
],
],
];
答案 0 :(得分:0)
您要发送电子邮件,因此您要使用的协议是smtp。 然后
'from' => [
'address' => env('MAIL_FROM_ADDRESS', 'The Email Address THAT I WANT TO USE'),
'name' => env('MAIL_FROM_NAME', 'THE NAME WHICH IS GOING TO APPEAR IN THE USER'S INBOX'),
],
或者代替3:
在您的env文件中,设置MAIL_FROM_NAME和MAIL_FROM_ADDRESS。