$mail = new PHPMailer(true);
try {
//Server settings
$mail->AddReplyTo('from@from.com','Post');
$mail->SMTPDebug = 1;
$mail->isSMTP();
$mail->Host = 'smtp.example.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Username = 'from@from.com';
$mail->Password = 'loginPassword';
$mail->Port = 465;
$mail->isHTML(true);
$mail->setFrom('from@from.com,'Name');
$mail->addAddress('to@to.com', 'Name');
//Content
$mail->isHTML(true);
$mail->Subject = $mailSub;
$mail->Body = $mailMsg;
$mail->AltBody = $mailMsgAlt;
$mail->send();
echo "Mail sent!;
}catch (Exception $e){
echo "Mail not sent! Try again.";
}
这就是我的代码的样子,其中定义了 $mailSub、$mailMsg、$mailMsgAlt 变量!你能帮帮我吗,我不明白为什么邮件总是进入垃圾邮件文件夹。
阿晨1998