ONE NET WIKI Free and professional IT Wiki

How to send an email via Gmail SMTP Server in Laravel

2018-09-04 ONE NET WIKI


In order to send an email via Gmail SMTP Server in Laravel, you may follow the following directions.

1. Gmail account setup

  • Login to your gmail account;


  • Select Google account > Sign In & Security > Sign in to google:

    enable two step verification [Enter your password again and a unique verification code that's sent to your phone], then generate app password, and you can use that app password in .env file.


  • Select Google account > Sign In & Security > Apps with account access (if necessary):

    enable "Allow less secure apps".


2. Laravel configuration setup

.env file will look like this:


or like this:



Note: Don't forget to run "php artisan config:cache" after you make changes in your .env file.

3. Laravel controller file:

$data = array('name'=>"Joshua", "body" => "This is my first Online Email.");
Mail::send('emails.mail', $data, function($message) {
  $message->to('TO_EMAIL_ADDRESS', 'To Website')
          ->subject('Online Email Test');
  $message->from('FROM_EMAIL_ADDRESS','From Visitor');

4. Laravel View file:


Hi <strong>{{ $name }}</strong>,

<p>{{ $body }}</p>
Editor's Note: All the articles in this website are original. If reproduced, please indicate the source and link.
All Comments (5)
Chun published at: 2020-01-16 13:37:26
Hi,Hello How Are You Today?I found you on web and I in reality liked your work. You pull off NOT need to bother approximately paying for hosting, auto emailing service, and domain name. Online Traffic has in its system an automaker that is easy to use. You just dependence to click on the alternating categories of leads and send an email to them via the auto mailer upon the website. Join here: Let's outlook it, no matter how good your opportunity or product is, you are not going to make any sales and build your opt in list if nobody sees your offer. To your success!
Dawn published at: 2019-11-05 09:04:26
Invite Bloggers and Webmasters to Fill out Paid Surveys I'm Dawn from Centtip. We are working with Inboxdollars to provide bloggers another opportunity to earn cash or get rewards. After joining Inboxdollars, you will be able to get rewards by sharing your opinions online ( Or Earn From Live Sex Cams). Paid surveys have been prepared for you: Regards, Dawn Frasure Unsubscribe:
Chung published at: 2019-09-28 09:26:24
It is very helpful. Thanks.0
Maryetta published at: 2019-09-26 13:34:21
Invite You to Test Our Product Hi,   I am Maryetta and the founder at Biglep. I’m reaching out to you because we are looking for health enthusiasts like you to test our prouct Rejuvenated Energy™. Rejuvenated Energy™ can help you Loss Weight, boost energy, and create a lasting feeling of rejuvenated wellbeing. We have prepared 1 jar for you. Get it at No Cost : Regards, Maryetta Baldyga UNSUBSCRIBE : Reply "no"
Trish published at: 2019-04-29 14:04:08
Invite You to Review Our Product Hi,   I am Trish from the American Beauty Association. I’m reaching out to you because we are looking for beauty enthusiasts like you to test our makeup brush. Go to test the Mieoko Flat Top Brush * Perfect for medium to heavy coverage that doesn't look caked on * Does not soak up excessive amounts of product. * 22,000 mink soft bristles for flawless powder or liquid makeup application * Does Not Shed! Thank you for your time, Trish
Expand to publish a comment

Web Development

Web Management

Web Marketing

Web Security