In the Laravel framework, send email instances (email verification) and laravel sends emails

Source: Internet
Author: User

In the Laravel framework, send email instances (email verification) and 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 = // 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


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



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 ();

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