How to Use Command Line in Laravel 9 to Send Test Emails Tutorial With Examples

Laravel is a PHP framework that gives us liberty and choice to present components on our web apps however we want. That’s the beauty of using Laravel in our projects. By using it with Tinker we would further simplify the use-cases in this tutorial that has both of them.

Testing Laravel app mail settings are as much important as setting them up to send emails without running into errors. So if you have set up your email in Laravel app you should test them before sending them. Laravel Tinker on command line is the quickest way to test Laravel mail settings whether emails are being sent or not.
We will test Laravel 9 mail settings with Tinker. Let’s open root prompt in Laravel or SSH into our server to start our tinker session.

php artisan tinker

Next send a quick mail with Mail facade for testing. If you are sending a test mail you need to use a test email. We can also use other methods like $msg->from(‘[email protected] and customize our email address.

Mail::raw('Hello World!', function($msg) {$msg->to('[email protected]')->subject('Test Email'); });

Once again it’s highly advisable to to test your Laravel email settings for errors and test them before using it. Let us know in the comments if you have any queries regarding Laravel mail setting errors we will try to answer them.