In the Laravel framework, send an email instance (email verification). laravel sends an email _ PHP Tutorial.

Source: Internet
Author: User
In the Laravel framework, send mail instances (email verification) and laravel send mail. In the Laravel framework, the Mail sending instance (email verification) is implemented. after a period of use, laravel finds that user verification is required in many parts of the project, send email instances (email verification) in Laravel framework using text message verification. laravel sends emails

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, this article briefly summarizes how to implement the Mail sending function in the Laravel framework and how to implement text message verification in the future .....

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 accountPOP3, SMTP, and IMAP must be enabled and the authorization code must be enabled 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$messageList 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 ();

Pull (email verification), laravel after sending an email for a period of time, it is found that user verification is required in many areas of the project, text message 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.