Testing Emails with Laravel Tinker
Nov
20

Testing Emails with Laravel Tinker

Email testing is an essential step in ensuring that your application can communicate with its users and SMTP server correctly setup. Artisan Tinker provides a quick and easy way to test email sending without creating dedicated mailable classes or controllers.

To test email sending using Artisan Tinker run the following command.

php artisan tinker


You can utilize the Mail::raw() method by using Mail facade. This method allows you to send a raw email message without creating a dedicated mailable class. The syntax for sending an email using Mail::raw() is as follows:

Mail::raw('Hello world!', function($msg) {
    $msg->to('[email protected]')->subject('This is a test email');
});

In this example, the Mail::raw() method sends the message "Hello World!". The $callback function receives the email message object and sets the recipient address and subject line using the to() and subject() methods, respectively.

 

Contact

Get in touch with us

Feel free to request missing tools or give some feedback.

Contact Us