How to integrate Zoho SMTP Mail Configurations in Laravel?

Recently in one of our projects we needed to use Zoho SMTP mail service to send emails.

Yasmin Bano , 01 December, 2020

The integration was quite simple. All you need to do is to set the Mail Configuration in the ENV of Laravel.

Still, it took us an entire day to make it work. Why?
As the information was quite scattered. I find out a few things from some different places, a few from the document and that’s how it finally started to work.
In this blog, I am writing out all the difficulties I’ve faced which will help you to do this task in a few minutes.
To send the email you need to configure the following parameters-

MAIL_DRIVER
This is easy, use the default value which is SMTP.

MAIL_HOST
If you do a google search or follow the Zoho document, you see everywhere that you need to use smtp.zoho.com as a MAIL_HOST.
But here is a little catch please do check in which region your account is created. For me, the account is in the Indian region so I need to use smtp.zoho.in instead of smtp.zoho.com.

MAIL_ENCRYPTION
The mail encryption can be SSL or TLS.

MAIL_PORT
The mail port will depend on MAIL_ENCRYPTION. For SSL choose 465 and for TLS you need to set the MAIL_PORT to 587.

MAIL_FROM_ADDRESS & MAIL_USERNAME
Both parameters will have the same value. The values should be the email address of the Zoho account.

For MAIL_USERNAME, there is no information about what should be the value of this parameter. The example you’ll see will provide a dummy value [email protected] but what you need to use is simply the email address of your Zoho account.
Ex. If I’ve created my account with [email protected] then the MAIL_USERNAME will be [email protected]

MAIL_PASSWORD
At many places, you’ll find that you need to use the password of your account but you need to use an app-specific password. You’ll need to generate an App Specific address from your Zoho account dashboard
Here is the detailed procedure you need to follow to generate the App-Specific Password
App Specific Password

So here’s the final look of your MAIL Configuration

If you have any queries, doubts, or improvements, Please comment.
Happy Coding!

blog comments powered by Disqus