In the code configurations above, the environment variables specify the following:
MAIL_MAILER: The email driver to use.
MAIL_HOST: The email host provider.
MAIL_PORT: The port to send the emails.
MAIL_USERNAME and MAIL_PASSWORD: The username and password for authentication.
MAIL_ENCRYPTION: The email encryption to use, such as SSL or TLS.
MAIL_FROM_ADDRESS: The email sender address.
MAIL_FROM_NAME: The name of the email sender.
Sending the email
Let’s consider an example of sending the order receipt to the user. For this purpose, we need to create the following:
OrderEmail.php: A mailable class.
order.blade.php: A blade view file.
EmailController.php: A Laravel controller to make use of the OrderEmail class.
Mailable class
Mailable in Laravel is a particular class responsible for configuring and sending emails. We create a Mailable class for each type of email we send. Create a Mailable class OrderEmail by following the artisan command: