How to send email via Cpanel SMTP server in Laravel
In this tutorial, we will learn How to send email via the Cpanel SMTP server in Laravel. Here, I will show how to configure email settings in Cpanel and use them for your Laravel application. Laravel default provides a free feature-rich library SwiftMailer to send emails. SwiftMailer to we can easily send emails without too many hassles.
- Step 1: Open Cpanel Dashboard
- Step 2: Click on the Email accounts
- Step 3: Click on the connected devices button
- Step 4: Configure your Laravel .env file
- Step 5: Send mail example
Step 1: Open Cpanel Dashboard
Login to your Cpanel Dashboard.
Step 2: Click on the Email accounts
Step 3: Click on the connected devices button
Here list of email accounts you might have created or else you can create new email accounts. Lists of email accounts in choice specific email account to click on the connected devices button found at the right corner.
Click on the connected devices button, it will redirect you to the Mail Client Manual Settings.
Step 4: Configure your Laravel .env file
.env
MAIL_MAILER=smtp
MAIL_HOST=outgoing_server
MAIL_PORT=outgoing_server_smtp_port
MAIL_USERNAME=info@example.com
MAIL_PASSWORD=******
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=info@example.com
MAIL_FROM_NAME="${APP_NAME}"
Step 5: Send mail example
Now test your Laravel mail sending.
Read this tutorial: How to Send Email in Laravel with Example