<?php
use PHPMailer\\PHPMailer\\PHPMailer;
use PHPMailer\\PHPMailer\\SMTP;
use PHPMailer\\PHPMailer\\Exception;
require './PHPMailer/src/Exception.php';
require './PHPMailer/src/PHPMailer.php';
require './PHPMailer/src/SMTP.php';
$mail = new PHPMailer(true);
try {
$mail->SMTPDebug = SMTP::DEBUG_SERVER;
$mail->SMTPAuth = true;
$mail->isSMTP();
$mail->Host = 'sg-smtp.qcloudmail.com';
$mail->Username = 'abc@qq.aa.com';
$mail->Password = '123456';
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mail->CharSet = PHPMailer::CHARSET_UTF8;
$mail->CharSet = 'UTF-8';
$mail->ContentType = 'text/plain; charset=UTF-8';
$mail->Encoding = PHPMailer::ENCODING_BASE64;
$mail->Port = 465;
$mail->setFrom('abc@qq.aa.com', 'fromName');
$mail->addAddress('test@test.com', 'toName');
$mail->addAttachment('./tmp.txt');
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
Was this page helpful?