[Mr. Mai] implement email verification in Laravel framework-send an email-after some time of use, Mr. Mai found that user verification is required in many areas of the project, taking Text Message verification and email verification as the mainstream trend, wheat summarized how to implement text message verification in the future if the Mail sending function is implemented in 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 ();