我对 PHP 很陌生。我从这里下载了一个 phpmailer 脚本(带文件)-> phpmailer
我正在使用 XAMPP,并将文件定位在:
\htdocs\QMS\phpmailer
我的 php 脚本位于:\htdocs\QMS\
我收到邮件已发送的消息,但我在收件箱、垃圾箱或垃圾邮件中看不到任何内容。我尝试了其他电子邮件地址,但仍然没有。
这是代码:(*电子邮件地址和姓名已被“xxx”屏蔽)
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$mail->AddReplyTo("xxxx@mycompany.com","xxx xxx");
$mail->SetFrom('xxxx@mycompany.com","xxx xxx');
$mail->AddReplyTo('xxxx@mycompany.com","xxx xxx');
$body = "This is a test... It works!";
$address = "xxxx@mycompany.com";
$mail->AddAddress($address, "xxx xxx");
$mail->Subject = "A subject line here";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment("images/phpmailer.gif"); // attachment
$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>