<?php
/*
可用新浪和网易邮箱测试成功,但QQ不成功!
下载 phpmailer 解压
http://phpmailer.worxware.com/ 要注意邮件服务器的端口号,默认是 25 不用修改,如果不是则要修改如下,在$mail->IsSMTP() ;下一行加上 $mail->Port = 端口号;
*/
require 'class.phpmailer.php'; $mail = new PHPMailer; $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.sina.com'; // SMTP 服务器 Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'mysina'; // SMTP username
$mail->Password = '******'; // SMTP password
$mail->SMTPSecure = ''; // Enable encryption, 'ssl' also accepted $mail->From = '[email protected]';
$mail->FromName = 'mysina';
$mail->AddAddress('[email protected]', 'Josh Adams'); // Add a recipient
//$mail->AddAddress('[email protected]'); // Name is optional
$mail->AddReplyTo('[email protected]', 'Information');
//$mail->AddCC('[email protected]');
//$mail->AddBCC('[email protected]'); $mail->WordWrap = 50; // Set word wrap to 50 characters
//$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 = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = '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;
exit;
}else{
echo 'Yes';
}