PHPMailer test, simple usage
<?php
/*
* 1. 使用 QQ 邮件服务进行发信,port, smtpsecure, host 参考腾迅邮箱的说明
* 2. setFrom 中的 email 地址须与 QQ 的邮箱帐户一致
* 3. 已发送的邮件并不会存放在 QQ 邮箱的发件箱
*/
require 'vendor/autoload.php';
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.exmail.qq.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'bugber@bugber.com'; // SMTP username
$mail->Password = '**********'; // SMTP password
$mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 465; // TCP port to connect to
$mail->setFrom('bugber@bugber.com', 'Notus');
$mail->addAddress('hehe_xiao@qq.com', 'hehe_xiao'); // Add a recipient
//$mail->addAddress('ellen@example.com'); // Name is optional
//$mail->addReplyTo('info@example.com', 'Information');
//$mail->addCC('cc@example.com');
//$mail->addBCC('bcc@example.com');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = '这是邮件的标题';
$mail->Body = '内容:This is the HTML message body <b>in bold!</b>';
$mail->AltBody = '不支持html的邮件内容:This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent';
}