时间:2021-07-01 10:21:17 帮助过:16人阅读
try
{
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->SMTPDebug = 0;
$mail->Host = "smtp.126.com"; // specify main and backup server
$mail->Port = 25;
$mail->Username = "[email protected]"; // SMTP username
$mail->Password = "******"; // SMTP password
$mail->From = $mail->Username;
$mail->FromName = "myname";
$mail->AddAddress("[email protected]", "toname");
$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Here is the subject";
$mail->Body = "This is the HTML message body in bold!";
$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
if(!$mail->Send())
{
echo "Mailer Error: ".$mail->ErrorInfo;
return false;
}
else
{
return true;
}
} catch (phpmailerException $e)
{
echo "Send mail failed: ".$e->errorMessage();
return false;
}
set_time_limit(0);
ini_set("max_execution_time", "18000000");
include 'PHPMailer/class.phpmailer.php';
$sendmail = '';//收件人
$title='我要发邮件';
$remark='这是邮件内容';
$mailer=new PHPMailer();
$mailer->CharSet = "utf-8";
$mailer->ContentType = 'text/html';
$mailer->IsSMTP();
$mailer->SMTPDebug = 0;
$mailer->SMTPAuth = true;
$mailer->SMTPSecure = 'ssl';
$mailer->Host = 'smtp.163.com';
$mailer->Port = '465';
$mailer->Username = '';//发件人邮箱
$mailer->Password = 'xxx';//发件人密码
$mailer->SetFrom('','');
$mailer->AddAddress($sendmail);
$mailer->Subject =$title;
$mailer->MsgHTML($remark);
for($i = 0; $i< 10; $i++){
$mailer->send();
sleep(3);
}
?>