51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
use PHPMailer\PHPMailer\PHPMailer;
|
|
use PHPMailer\PHPMailer\SMTP;
|
|
|
|
require FCPATH . "vendor/PHPMailer/src/Exception.php";
|
|
require FCPATH . "vendor/PHPMailer/src/PHPMailer.php";
|
|
require FCPATH . "vendor/PHPMailer/src/SMTP.php";
|
|
class Xtest extends MY_Controller {
|
|
function __construct() {
|
|
parent::__construct();
|
|
echo "FC PATH : " . FCPATH ;
|
|
}
|
|
function info() {
|
|
$mail = new PHPMailer();
|
|
$mail->SMTPDebug = 2;
|
|
$mail->isSMTP();
|
|
$mail->Host = 'smtp.gmail.com';
|
|
$mail->Port = 587;
|
|
$mail->SMTPAuth = true;
|
|
$mail->Username = 'sas.test.2023@gmail.com';
|
|
$mail->Password = 'Sas!102938';
|
|
$mail->SMTPSecure = "tls"; //PHPMailer::ENCRYPTION_SMTPS;
|
|
//sender information
|
|
$mail->setFrom('sas.test.2023@gmail.com', 'Sasana');
|
|
//
|
|
////receiver email address and name
|
|
$mail->addAddress('padmanto@gmail.com', 'padmanto');
|
|
//
|
|
// Add cc or bcc
|
|
// $mail->addCC('email@mail.com');
|
|
// $mail->addBCC('user@mail.com');
|
|
|
|
|
|
$mail->isHTML(true);
|
|
|
|
$mail->Subject = 'PHPMailer SMTP test';
|
|
$mail->Body = "<h4> PHPMailer the awesome Package </h4>
|
|
<b>PHPMailer is working fine for sending mail</b>
|
|
<p> This is a tutorial to guide you on PHPMailer integration</p>";
|
|
|
|
// Send mail
|
|
if (!$mail->send()) {
|
|
echo 'Email not sent an error was encountered: ' . $mail->ErrorInfo;
|
|
} else {
|
|
echo 'Message has been sent.';
|
|
}
|
|
//
|
|
$mail->smtpClose();
|
|
}
|
|
}
|