@herminia_bruen
Sending email in Laravel is a straightforward process. Here's how you can send an email in Laravel:
1
|
php artisan make:mail MyTestMail |
This will create a new file in the app/Mail
directory with the name MyTestMail.php
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
use AppMailMyTestMail; use IlluminateSupportFacadesMail; public function sendEmail() { $details = [ 'name' => 'John Doe', 'message' => 'This is a test email from Laravel.' ]; Mail::to('[email protected]')->send(new MyTestMail($details)); return "Email sent successfully"; } |
Replace the email address in the to
method with the recipient's email address.
That's it! You have successfully sent an email in Laravel. Remember to check your email client to see if the email has been delivered.