Tips & Tidbits

Sending a Laravel test email from the command line

If you've just finished setting up your mail settings for your Laravel app you probably want to give them a test. You could dive into your app and perform an action that results in an email being sent, but there's a quick and easy way to test them via Laravel Tinker on the command line.

SSH into your server or open a prompt in the root of your Laravel project and start a tinker session.

php artisan tinker

Then, use the Mail facade to send a quick test email. Make sure to change your email. You can also chain any of the other methods on a normal email here. For example, you could use $msg->from('mysender@app.com') to customise the sender email address.

Mail::raw('Hello World!', function($msg) {$msg->to('myemail@gmail.com')->subject('Test Email'); });

Additional Reading

Laravel Mail Docs