How to use SMTP to send mail in Laravel (for 163, QQ, Gmail, etc.)

Source: Internet
Author: User
Laravel4and Laravel5Messages are sent in exactly the same way. Laravel5The mail is sent in Chinese document in: http://Laravel-china.org/docs/5.0/mail

In this article, I will163The mailbox, for example, shows how to send a message using the Laravel built-in mail delivery class.
Configuration
Modify the Mail send configuration.4.2In app/config/mail.php,5In config/mail.php, modify the following configuration:
'Host'='smtp.163.com',
'Port'= -,
' from'= = Array ('Address'='***@163.com','name'='Testmail'),
'username'='***@163.com',//Note that this must be the same as the email address in the previous line of configuration
'Password'='****',
Send
In the controller or model, call the following code: $DATA = ['Email'= $email,'name'= $name,'UID'= $uid,'Activationcode'= $code];
Mail::send ('Activemail', $data, function ($message) use ($data)
{
$message->to ($data ['Email'], $data ['name'])->subject ('Welcome to register our website, please activate your account! ');
});


The message view is views/activemail.blade.php:

<!doctype html>
"ZH-CN">
<meta charset="UTF-8">
<meta http-equiv="x-ua-compatible"Content="Ie=edge">
<body>
<a href="{{{URL (' active?uid= '. $uid. ') &activationcode= '. $activationcode)}}"target="_blank"> Click to activate your account </a>
</body>

How to use SMTP to send mail in Laravel (for 163, QQ, Gmail, etc.)

Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

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.