[Mr Mai] implement email verification in Laravel framework --- send email, laravel ---
After a period of use, it is found that user verification is required in many areas of the project, and text message verification and email verification are the mainstream trends, wheat summarizes how to implement text message verification in the future if the mail sending function is implemented in the Laravel framework .....
Under the. env file
1. Configure the Laravel File
MAIL_DRIVER = smtp // we recommend that you use smtp.
MAIL_HOST = smtp.163.com // an error is reported when you use the 163 mailbox QQ mailbox.
MAIL_PORT = 25 // smtp is 25 by default
MAIL_USERNAME = null // your 163 account
MAIL_PASSWORD = null // client Password
MAIL_ENCRYPTION = null
.
2. Modify the config/email. php file
'From' => ['address' => null, 'name' => null], // No prompt is displayed in the manual, but in actual application, if it is addredd => null, an error is returned. You need to write your 163 address every day.
3. register the 163 mailbox and set the mailbox account POP3/SMTP/IMAP to enable and enable the authorization code for mobile phone verification.
4. Refer to the send email in Laravel manual.
Note that the use Mail must be referenced first when the Controller references the email to be sent.
Test email sending
Set in route
Write method in Controller
Where
1: Mail: raw is used to send native data, and other content Sending methods are provided in the Manual;
2. $ message-> subjuet (''); is the file title
3. $ message-> to (); sent
This is a copy$message
List of methods available in the message generator instance:
$ Message-> from ($ address, $ name = null); $ message-> sender ($ address, $ name = null); $ message-> to ($ address, $ name = null); $ message-> cc ($ address, $ name = null); $ message-> bcc ($ address, $ name = null ); $ message-> replyTo ($ address, $ name = null); $ message-> subject ($ subject); $ message-> priority ($ level ); $ message-> attach ($ pathToFile, array $ options = []); // append a file with the original $ data string... $ message-> attachData ($ data, $ name, array $ options = []); // gets the underlying SwiftMailer message instance... $ message-> getSwiftMessage ();