Table of Contents
Lots of web server do not allow to directly send email from website .They require SMTP authentication for security purpose.
Below we have created a laravel tutorial for Sending email and configuring SMTP in web server .
These configuration can find from the same page that we created email .
Now you will be able to send email from your Laravel application . To send mail , find below example code
Step 1 : Create email
To use SMTP , we need to first create email id of our domain name ex: contact@domain.com . So, to do this open your website cpanel ex: www.domain.com/cpanel / Now access link 'Email Account' . There mention your email id ,password then click 'Create Account' .Step 2 : Copy SMTP details
Here we have to copy SMTP details i.e
These configuration can find from the same page that we created email .
- Scroll to bottom of the page . Find your email , on right side click on 'Set Up Mail Client'
- Now on newly opened page , scroll quite middle of the page ,find there 'Mail Client Manual Settings'
- Find SMTP details on ' Secure SSL/TLS Settings ' or 'Non-SSL Settings' panel
- SMTP username is your email id
- SMTP password is your email's password that we created on 1st step
- SMTP host is mentioned on ''Outgoing Server:' ex: mail.domainname.com
- SMTP port is mentioned on 'Outgoing Server:' ex: 25
Step 3: Put SMTP details on laravel's config/mail.php
- Put mail driver SMTP ex : driver 'driver' => env('MAIL_DRIVER', 'smtp')
- Put SMTP host ex: 'host' => env('MAIL_HOST', 'mail.domainname.com')
- Put SMTP port ex : 'port' => env('MAIL_PORT',25)
- Put SMTP username ex : 'username' => env('contact@domainname.com')
- Put SMTP password ex: 'password' => env('contact@abc')
Now you will be able to send email from your Laravel application . To send mail , find below example code