Send Email Using Google Mail, Ajax, Sweet Alert2 and RestAPI with Template in Laravel 5.8
- Clone or Download repository
- In project directory type command : composer install
- Create .env file from .env.example (With console)
-
Configure the email in the env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465 *port mail server (TLS: 587 | SSL: 465)
MAIL_USERNAME=*your gmail address (to be an email server)
MAIL_PASSWORD=*your password of gmail address
MAIL_ENCRYPTION=ssl *method mail ecryption (tls | ssl)
-
Configure the email in App/Http/Controllers/ApiSendMailController.php
Mail::to('*Your Email')->send(new SendMail($data));
-
Serve your project : php artisan serve
-
Test in your browser : http://localhost:8000/sendfeedback