bag*_*ilk 2 php smtp phpmailer
我是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!";
}
?>
Run Code Online (Sandbox Code Playgroud)
我知道我参加聚会很晚,但是如果有人在这里绊倒了,并且正在寻找一种在本地主机上尝试发送电子邮件的快速解决方案,则可以使用这个不错的免费软件在您的计算机上运行一个伪造的SMTP服务器。 “查看”真实的SMTP服务器将已经接收和发送的电子邮件(它实际上不发送任何内容)。
http://nilhcem.github.io/FakeSMTP/
在开发和测试期间超级有用。