由于本人项目发邮件次数比较多,而每个邮箱地址最大上限每日1000封受限。
为了避免第一个邮箱账号达到每日上限(邮件异常会返回错误码554,提示:Expected response code 354 but got code "554", with message "554 5.5.3 RP:TRC),项目还继续发送邮件,则启动备用邮箱号发送。
第一步:首先先配置.env配置备用邮件账号数据
#备用邮箱号 BACKUP_MAIL_DRIVER=smtp BACKUP_MAIL_HOST=smtp.qiye.163.com BACKUP_MAIL_PORT=465 BACKUP_MAIL_USERNAME=XXXXX@kingyee.com.cn BACKUP_MAIL_PASSWORD=XXXXXXXXXXX BACKUP_MAIL_FROM_ADDRESS=XXXXX@kingyee.com.cn BACKUP_MAIL_FROM_NAME=XXXXX系统(备用) BACKUP_MAIL_ENCRYPTION=ssl
第二步:在config目录新建文件名为backupMail.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('BACKUP_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('BACKUP_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('BACKUP_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('BACKUP_MAIL_FROM_ADDRESS', 'hello@example.com'),
'name' => env('BACKUP_MAIL_FROM_NAME', 'Example'),
],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol
|--------------------------------------------------------------------------
|
| Here you may specify the encryption protocol that should be used when
| the application send e-mail messages. A sensible def