🔥50% off, christmas big sale 🔥 on all of products, View More, View at CodeCanyon

Configure SMTP to send Emails in Laravel

1 yearago Read time : 1 Minute

Getting Started

First of all, you need to get a service from an SMTP Email service provider and configure smtp to your app, they will provide you SMTP credential for sending email using your Laravel Application. You can also ask your hosting provider first if they allow you to send SMTP email, so you can send email also from your hosting provider SMTP credential.

I am going to tell all of possible way to send or enable email from Laravel, although it’s the same way as you send Email from PHP, we will do it laravel way.

Lists of SMTP Email Providers

Amazon SES
Most cheap email service provider, see there Pricing.
Free plan – Amazon SES lets you send 62,000 emails/month free if you are an EC2 user (EC2 users are those users who purchase the Amazon service). Additionally, you will also receive 1,000/month for free.
Price – They will charge you only $0.10 per thousand emails, which is $1 for sending 10,000 emails

Sendgrid

Sendgrid is also a better service for sending emails, Also you can set your schedule campaigns to send emails a specific time.
Sendgrid offering 12,000 emails completely free per month. Sendgrid provides a PHP library to send email from any PHP application. Though we are using laravel, so we do not need any of library.

Laravel offer the best email library called SwiftMailer PHP Library since it’s first version to get engage with your customers or subscribers.

Mailgun
Mailgun is one of the best SMTP email service provider lets you send 10,000 emails per month for free, and $15 for 40,000 emails. It’s is easy to use. You can also access their API or dashboard to monitor your emails stats.
However, signup any of these email providers or you can choose any others who will provide you SMTP credential.

Setting SMTP to Laravel

Configure smtp credential to .env file in your root directory and save, an example is below

MAIL_DRIVER=smtp
MAIL_HOST=smtphost
MAIL_PORT=2525
MAIL_USERNAME=[SMTP_USERNAME]
MAIL_PASSWORD=[SMTP_PASSWORD]
MAIL_ENCRYPTION=null

That’s it, your application now should start sending the email if your application has email sending features, or you can write code for sending the email. Get email example from laravel documentation

https://laravel.com/docs/5.1/mail


About the Author

themeqx