How to use SMTP on Laravel
Laravel is a PHP framework that has been featured today by many developers thanks to its unique features.
Set up SMTP in Laravel
Setting SMTP or sending emails in Laravel, like other infrastructure settings are done in the env file. So whether you want to use a SMTP server or SMTP host, you only need the following code in the env file. This file is located in the Laravel main folder.
In this article, we will go through using SMTP hosts.
In order to do this, you first need to create an email address on your web host and then create the following code in the env file. Enter the main folder.
The codes required to use SMTP in Laravel are as follows.
MAIL_DRIVER = smtp
MAIL_HOST = host name of server host
MAIL_PORT = 587
MAIL_PASSWORD = password
MAIL_ENCRYPTION = zero
MAIL_DRIVER: In this section, you should specify the type of email that will be the same SMTP.
MAIL_HOST: The email address of the email will be entered in this section, which is the same as the domain name or the name of your email server.
MAIL_PORT: Enter the port server to receive email from LARAVEL side on this line.
MAIL_USERNAME: Enter the email address you created on your server or host.
MAIL_PASSWORD: Enter your email account password at Hat.
MAIL_ENCRYPTION: The type of email encryption in this section can be specified that it should be placed on tls or null.
After adding the code above, save the file and exit it.
In this way, the settings required to send email via SMTP in Laravel are completed and read for use.
Note: You will also be able to use Gmail's SMTP through the same settings.