How to Setup and Test SMTP settings

SMTP stands for Simple Mail Transfer Protocol. With the help of correct SMTP settings you are able to send confirmation and other general emails. ( SMTP Wikipedia article )

Services you can use for SMTP

You can use any mailing service you want. Here are some of theme

Note:- Make sure some hosts block the use of 3rd party mailing services. In that case you have to use your own smtp server.

Q: Why Mandrill is preferred ?

A: It's free. No chance of Spams, No change domain get blacklisted because of mails, Mail tracking, 100% uptime and much more

How to setup

  1. Open app/config/mail.php
  2. Provide your server SMTP details in that.
  3. Every line is properly commented you can read the comments to know more about individual settings

How to Test Settings

  1. Turn of the debug mode ( Debug mode details is provided in main docs )
  2. Open app/routes.php
  3. Just after <?php tags place this code and save the file

.

Route::get('test',function(){
    $data = array(
        'fullname'   => 'test',
        'username'   => 'test',
        'activationcode' => rand(5, 2000),
    );
    Mail::send('emails.registration.welcome', $data, function ($message) {
        $message->to('Your Email here', 'TEST')->subject('Welcome to ' . siteSettings('siteName'));
    });
    return 'Success';
});

Make sure to replace Your Email Here with your email address where you want to receive a test email

After that visit example.com/test

If you see Success returned in your browser that means your settings are correct

If you see any error message, that means your settings are not correct


© Abhimanyu Sharma ( abhimanyusharma003 ) || Twitter: @abhimanyu003