Laravel Mail Configuration On Shared Hosting Cpanel - FreeCodeBlog

Last updated: Nov 25, 2021

Want to configuration laravel mail on cpanel shared hosting? Actually after successfully deploy laravel project on shared hosting cpanel you need to configuration laravel mail details to send email notification to users, admins and others. So at first you need to deploy laravel project for laravel mail configuration on shared hosting cpanel. You need to configuration model, mail config, env file, cache clear for laravel mail configuration on cpanel shared hosting. You need to use cpanel email account's SSL information like smtp, port, username, password and more for laravel mail configuration on shared hosting cpanel. So don't be late. Let's start to reading.

 

 

1. Model Configuration.

At first you need to do model configuration before deploy laravel project on cpanel shared hosting. In model class, don't forget to use laravel mail notifiable in users or admins or customers or others models. Make sure that tables include with email flied. You may receive error messages if you do not use this in model class. So it is important to use notable laravel mail in model class. If you forgot to use the model class configuration before deployment on shared hosing cpanel, you need to go cpanel public_html (or where you did uploaded laravel project) and configure the model class as soon as possible.

 

use Illuminate\Notifications\Notifiable;
use Notifiable;

 

2. Deploy Laravel On Cpanel.

Now you need to deploy laravel project on shared hosting cpanel for laravel mail configuration. You can deploy laravel project on shared hosting cpanel using too many ways. If you did not deploy laravel project on shared hosting yet then deploy it on shared hosting cpanel. Still don't know how to set up Laravel project in Cpanel? In fact I have already created some tutorials on installing Laravel project in Cpanel. So you need to read deploy laravel project to shared hosting cpanel using zip file tutorial for laravel deployment.

 

3. Create An Email Account.

Haven't created an email account yet? You can't laravel mail configuration on shared hosting cpanel without an email account. So it's very very important to create an email account from cpanel shared hosting. Now go to email accounts section from cpanel dashboard to create an email. If you already created an email account then follow next steps otherwise read firstly how to create an email account from cpanel for configuration mail on cpanel laravel project. Please don't forget to collect mail information from connect devices section. You can see connect devices option on email accounts list page. You need to collect mail client manual settings secure SSL/TLS Settings (Recommended) information.

 

4. Laravel Env Configuration.

After deploy laravel project on shared hosting and create an email from cpanel you need to configuration cpanel mail in laravel .env file. So go to cpanel dashboard and click on the “file manager” to open cpanel file manager public_html folder. go to laravel project root folder and find .env file. Now open laravel env file and edit it to configure mail information. You need to use mail username as a no-reply@your-domain (don't forget to use your created email account username), mail mailer as a smtp, mail host as a www.domain-name.domain-extension, mail port as a 465 (don't forget to use your created email account's outgoing smtp port), mail password as a created email account's password, mail encryption as a SSL if you want to use secure SSL/TLS Settings (Recommended) option.

 

MAIL_MAILER=smtp
MAIL_HOST=www.your-website-domain-name
MAIL_PORT=465
MAIL_USERNAME=name@your-website-domain-name
MAIL_PASSWORD=your-email-account-password
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=name@your-website-domain-name
MAIL_FROM_NAME="${APP_NAME}"

 

Once the mail details have been defined and saved you can check everything OK or not by seeing your cpanel email information.

 

Secure SSL/TLS Settings (Recommended)
Username: 	no-reply@your-domain
Password: 	Use the email account’s password.
Incoming Server: 	your-domain
IMAP Port: 993 POP3 Port: 995 
Outgoing Server: 	your-domain
SMTP Port: 465 
IMAP, POP3, and SMTP require authentication.

 

Now try to send email notification by registered user or sending manually. If mail will send to user or admin email then congratulation otherwise make sure your env mail information was correct.

 

5. Laravel Mail Config File Configuration.

If you did laravel model configuration properly then you can check laravel mail information from laravel config folder's mail.php file. Make sure you defined laravel mail connection as a “smtp” for laravel mail configuration on cpanel. You may need to clear cache after changed config folder's mail.php file. So don't forget to follow next step.

 

'default' => env('MAIL_MAILER', 'smtp'),

 

6. Clear Laravel Cache.

Please try again to send the email. Have you tried sending an email? Yes. Okay laravel mail configuration still not working on cpanel shared hosting? No. In fact, sometimes laravel mail configuration may not work properly after configuring all mail configuration in cpanel shared hosting. In this case you need to remove the cache from the laravel project in cpanel via terminal or laravel route. Please try sending an email again after clearing the cache from laravel project.

 

 php artisan config:cache
 php artisan cache:clear

 

Okay so this is for today. See you again next tutorials. Thanks

Post Tags
Post Writer
masum7323
Masum Biswas (@masum7323)

My name is Masum Biswas. I'm a full stack developer. I live in Bangladesh and I love to write tutorials and tools that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, MySQL, VueJS, Tailwind CSS and Bootstrap from the early stage.

Follow Me On
Related Posts
Use Laravel Socialite Package To Make A Login With Facebook

You can easily create login with facebook system in laravel using laravel first party package (laravel socialite). In this tutorial I will show you... Read More

Make One To One Chat Application In Laravel With Vue Js

Today I will make a one to one chat application in laravel with vue js. To making one to one chat application use can easily use jetream user authe... Read More

Configure Laravel Project After Deploy On Shared Hosting Cpanel

Did you deploy the Laravel project to the shared hosting cpanel? Yes. Good, Have you configured the Laravel project after deploying on the shared h... Read More

How To Use Laravel Mailtrap To Send Email

Mailtrap in laravel! Want to send fake email to mailtrap dashboard using laravel? Yes. Want to send laravel email notification to mailtrap? Yes. Do... Read More

How To Create Mysql Database On Shared Hosting Cpanel

Do you want to create a MySQL database in cpanel? Yes. Want to use MySQL database information in PHP, Laravel website? Yes. Okay before deploy PHP,... Read More