phpmailer with laravel

Solutions on MaxInterview for phpmailer with laravel by the best coders in the world

showing results for - "phpmailer with laravel"
Erica
01 Oct 2017
1<?php
2namespace App\Http\Controllers;
3
4use PHPMailer\PHPMailer;
5
6class testPHPMailer extends Controller
7{
8    public function index()
9    {
10        $text             = 'Hello Mail';
11        $mail             = new PHPMailer\PHPMailer(); // create a n
12        $mail->SMTPDebug  = 1; // debugging: 1 = errors and messages, 2 = messages only
13        $mail->SMTPAuth   = true; // authentication enabled
14        $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
15        $mail->Host       = "smtp.gmail.com";
16        $mail->Port       = 465; // or 587
17        $mail->IsHTML(true);
18        $mail->Username = "testmail@gmail.com";
19        $mail->Password = "testpass";
20        $mail->SetFrom("testmail@gmail.com", 'Sender Name');
21        $mail->Subject = "Test Subject";
22        $mail->Body    = $text;
23        $mail->AddAddress("testreciver@gmail.com", "Receiver Name");
24        if ($mail->Send()) {
25            return 'Email Sended Successfully';
26        } else {
27            return 'Failed to Send Email';
28        }
29    }
30}
31
Stone
07 Nov 2019
1composer require phpmailer/phpmailer
2