Configuration of 163 Mailbox Accounts
First of all, 163 mailboxes are needed. Here, 163 mailboxes must be set up to open SMTP services and set passwords.
Modify the. env file in the laravel root directory to set up the contents of the mailbox:
MAIL_DRIVER=smtp MAIL_HOST=smtp.163.com MAIL_PORT=465 MAIL_USERNAME=YOUR-EMAIL-NAME MAIL_PASSWORD=YOUR-163-PASSWORD //Password is the password you set for SMTP, not the login password MAIL_ENCRYPTION=ssl MAIL_FROM_ADDRESS=YOUR-EMAIL MAIL_FROM_NAME=YOUR-NAME
Note that above, if your website does not open ssl, you need to set the port MAIL_PORT to 25, and set MAIL_ENCRYPTION=null
Modify mail.php under config folder
'from' => [ 'address' => env('MAIL_FROM_ADDRESS', YOUR-EMAIL'), 'name' => env('MAIL_FROM_NAME', 'YOUR-NAME'), ],
Test Sending Mail Function
- Create a Send Mail Test Class:
You need to switch to the laravel root directory to execute the following commands
php artisan make:mail TestMail
This command creates a TestMail.php file in the app/Mail directory, and modifies the build method of the mailable class TestMail as follows:
public function build() { return $this->subject('Test mail')->view('emails.test'); }
Views are used above. We need to create an emails directory in the resources/views directory and a test.blade.php file in the emails directory, as follows:
A test email from the laravel test site!
- Use Tinker to test the sending mail function:
error
- The website does not open ssl
PHP Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol in /www/wwwroot/abc/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 267 PHP Warning: stream_socket_client(): Failed to enable crypto in /www/wwwroot/abc/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 267 PHP Warning: stream_socket_client(): unable to connect to ssl://smtp.163.com:25 (Unknown error) in /www/wwwroot/abc/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 267 Swift_TransportException with message 'Connection could not be established with host smtp.163.com [ #0]'
When your website does not have ssl, but you configure MAIL_ENCRYPTION=ssl, the above error will occur.
- Error in port setting
Port setting error message:
PHP Warning: stream_socket_client(): unable to connect to smtp.163.com:225 (Connection refused) in /www/wwwroot/abc/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/StreamBuffer.php on line 267 Swift_TransportException with message 'Connection could not be established with host smtp.163.com [Connection refused #111]'
Reference to port settings for sending mailboxes: http://help.163.com/10/0731/11/6CTUBPT300753VB8.html
Reference resources:
https://laravelacademy.org/post/9743.html
http://help.163.com/10/0731/11/6CTUBPT300753VB8.html