Using the mail sending feature in the Laravel framework

Source: Internet
Author: User

Here is the function of activating mail after the demo user has registered.

After clicking on the registration, the system will automatically send an email to the registrant's email, and the registrant can activate the account by clicking on the link.

Configure the (. env) file in Laravel first

mail_driver=smtp//Driver mail_host=smtp.sina.com//mail server address mail_port=25//port Mail_username=183****[email protected]// Your e-mail mail_password=**********hai//your e-mail password mail_encryption=null

Then configure the (email.php) file in the Laravel

' From ' = [' address ' = ' 183****[email protected] ', ' name ' = ' book Mall '],

After that, I went to the controller to write the code.

       $member = new Member ();            $member->email = $email;            $member->password = MD5 (' BK ' + $password);            $member->save ();            $uuid = Uuid::create ();            $m 3_email = new M3email ();            $m 3_email->to = $email;            $m 3_email->cc = ' 183****[email protected] ';            $m 3_email->subject = ' book Mall '; $m 3_email->content = ' Please click on the link within 24 hours to complete the verification, http://localhost/book/public/service/validate_email '. '? Member_id= '. $member->id. '            &code= '. $uuid;            $tempEmail = new Tempemail ();            $tempEmail->member_id = $member->id;            $tempEmail->code = $uuid;            $tempEmail->deadline = Date (' y-m-d h:i:s ', Time () +24*60*60);            $tempEmail->save ();mail::send (' Email_register ', [' m3_email ' = $m 3_email],function ($m) use ($m 3_email) {$m->to ($m 3_ema            Il->to, ' respectable user ')->cc ($m 3_email->cc)->subject ($m 3_email->subject); });//This piece of code is a method of the mail class

  

Using the mail sending feature in the Laravel framework

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.