Laravel sends an email. laravel sends an email to an instance.
Here, 163 is used as an example:
1 ,. env file configuration and mail. php configuration (used by default. env) 2 3 MAIL_DRIVER = smtp 4 MAIL_HOST = smtp.163.com 5 MAIL_PORT = 465 6 MAIL_USERNAME = Account 7 MAIL_PASSWORD = Authorization code 8 MAIL_ENCRYPTION = SSL 9 10 parameter description: 11 host is the host where the mailbox is located, for example, if we use a 163 mailbox, the corresponding value is smtp.163.com. If we use a QQ mailbox, the corresponding value is smtp.qq.com. 12 port is used to configure the mail sending service port number. For example, the default value is 25. If SMTP is set to use SSL encryption, this value is 465. 13 encryption indicates the encryption type. If it is set to null, it means no encryption is used, or it can be set to tls (port number is 25) or ssl. 14 username indicates the mailbox account, for example, yaojinbu@163.com15 password indicates the corresponding login password for the mailbox login. Note that you should enable POP3 | the key provided by the SMTP service in your QQ mailbox. 16 17 2. Send email 18 (use template) view emails under the root directory. blade. php19 $ name = 'wang baohua'; 20 $ flag = Mail: send ('elastic', ['name' => $ name], function ($ message) {21 $ to = '1970 @ qq.com '; 22 $ message-> to ($ to)-> subject ('mail test'); 23 }); 24 if ($ flag) {25 echo 'the email is sent successfully. Please check it! '; 26} else {27 echo' failed to send the email. Please try again! '; 28} 29 30 (plain text) 31 Mail: raw ('Hi, I'm a PHP program! ', Function ($ message) {32 $ to = '1970 @ qq.com'; 33 $ message-> to ($) -> subject ('text-only mail test'); 34 });