Implement Send mail instance (mailbox verification) in Laravel framework, laravel send mail _php tutorial

Source: Internet
Author: User
Tags email account

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 ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.