<?php
require('phpmailer/class.phpmailer.php');
require('phpmailer/class.smtp.php');

$mailer = new PHPMailer();

// 使用SMTP形式发送
$mailer->IsSMTP();
// 编码
$mailer->CharSet = 'utf-8';
// 启用SMTP调试功能(1 = errors and messages, 2 = messages only)
$mailer->SMTPDebug = 1;
// 启用SMTP验证功能
$mailer->SMTPAuth = true;

// HTML内容格式
$mailer->IsHTML();

// smtp服务器, 发送邮箱帐号公司的SMTP服务器(stmp.kyzy.cc),我这里使用的是mail.kyzy.cc
$mailer->Host = 'mail.kyzy.cc';
// SMTP服务器的端口号
$mailer->Port = '25';
// 这里填写发件邮箱账号
$mailer->Username = '[email protected]';
// 这里填写发件邮箱的密码
$mailer->Password = 'xxxxxxxxxxxx';

// 收件人
$to = '[email protected]';
$mailer->AddAddress($to, 'aaaaaaaa');
// 多人发送
//$mailer->AddAddress('[email protected]', 'nickname2');

// 增加"列表取消订阅头"
//$messageId = md5($to);
//$unsubscribeUrl = "https://www.kyzy.cc/unsubscribe_url.php?unsubscribe_id={$messageId}";
//$mailer->addCustomHeader("List-Unsubscribe: <mailto:{$mailer->From}?subject=Unsubscribe>, <{$unsubscribeUrl}>");
// 事实证明$unsubscribeUrl这块的参数根本没鸟用,看遍了internet就没发现哪家邮件服务器会鸟你,依然是给你发送退订邮件。
$mailer->addCustomHeader("List-Unsubscribe: <mailto:{$mailer->From}?subject=Unsubscribe>");


// 附件的绝对位置,上传后附件的名称
//$mailer->AddAttachment('D:\face.jpg', 'face2012.jpg');

// 发送标题
$mailer->Subject = '来自kyzy.cc的注册确认邮件';
// 发送人的地址
$mailer->From = '[email protected]';
// 发送人的名称
$mailer->FromName = 'RegSkynet';

// 主体内容
$mailer->Body = '好哈哈测试';
// 附加信息
$mailer->AltBody = '附加信息abc';

if (!$mailer->send()) {
    echo '邮件发送失败</br>';
    echo '错误原因:' . $mailer->ErrorInfo;
}
else {
    echo '邮件发送成功';
}

[button color="info" icon="" url="" type="round"]推荐相关文章[/button]
[post cid="101" /]