configure your preferred email driver to deliver the email v
For testing purposes, you can create an account on mailtrap.io and configure the mail settings on the .env file
Open .env and your version of the below
MAIL_DRIVER=smtp MAIL_HOST=smtp.mailtrap.io MAIL_PORT=2525 MAIL_USERNAME= MAIL_PASSWORD= MAIL_ENCRYPTION=tls MAIL_FROM_ADDRESS="your@gmail.com" MAIL_FROM_NAME="${APP_NAME}"
Create a Controller
php artisan make:controller TestEmailsController
In app/Http/Controllers/TestEmailsController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Mail;
class TestEmailsController extends Controller
{
//
public function html(Request $request)
{
$data = array('name'=>"Harry Howdy");
//
Mail::send('email.test', $data, function($message) {
$message->to('butlerjraines@gmail.com');
$message->from('support@youremail.com', 'Your Site Name');
$message->subject('Welcome to Laravel Email Tutorial');
});
}
}
Add route to routes/web.php
use App\Http\Controllers\TestEmailsController;
Route::get('/test-email', [TestEmailController::class, 'email']);
Copy the following code in resources/views/email/test.blade.php file.
<h1>Hi, {{ $name }}</h1>
<p>Sending Mail from Laravel.</p>
- Log in to post comments