Send mail instance (mailbox verification) in Laravel framework, laravel send mail
After a period of use, found in many areas of the project need to use user authentication, SMS verification and mailbox verification as the mainstream trend, this article small to summarize how to achieve in the Laravel framework to send the mail function, will be more on how to achieve SMS verification later on.
Under the. env file
1. Configuring the Laravel File
MAIL_DRIVER=SMTP//SMTP method recommended
Mail_host=smtp.163.com//Suggested use 163 mailbox QQ mailbox will have an error
MAIL_PORT=25//SMTP defaults to 25
Mail_username=null//Own 163 account
Mail_password=null//Client password
Mail_encryption=null
2. Modify the config/email.php file in the
' From ' + [' address ' = null, ' name ' = null],//not indicated on the manual, but the actual application if the Addredd=>null is error, need to write their own 163 address
3. Register 163 mailbox and make email account settings Pop3/smtp/imap to open and activate the authorization code and verify the phone
4. Refer to the e-mail sent in the Laravel manual
It is important to note that the use mail must be referenced first when the controller refers to a message being sent
Send a message test
Set in Routing
Writing methods in the controller
which
1:mail::raw is the sending of native data, and the other means of sending the content are provided in the manual;
2. $message->subjuet ("); is the title of the file
3. $message->to (); Send to whom
This is a $message
list of methods that can be used in a 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 to the original $data string ... $message->attachdata ($data, $name, array $options = []);//Get The underlying Swiftmailer message instance ... $message->getswiftmessage ();
http://www.bkjia.com/PHPjc/1133125.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133125.html techarticle in the Laravel framework to implement the sending mail instance (mailbox authentication), Laravel send mail after a period of use, found in the project many places need to use user authentication, SMS verification ...