我正在使用wamp服务器和PHPMailer发送测试电子邮件。这是我的代码:
<?php
require_once ("includes/PHPMailer/class.phpmailer.php");
require_once ("includes/PHPMailer/class.smtp.php");
require_once ("includes/PHPMailer/language/phpmailer-lang-en.php");
$to_name = "Junk mail";
$to = "myemail@yahoo.com";
$subject = "Mail Test at" .strftime("%T", time());
$message = "This is a test.";
$message = wordwrap($message, 70);
$from_name = "My Name";
$from = "myemail@gmail.com";
//PHP mail version (default)
$mail = new PHPMailer();
try {
$mail->FromName = $from_name;
$mail->From = $from;
$mail->AddAddress($to, $to_name);
$mail->Subject = $subject;
$mail->Body = $message;
$mail->SMTPDebug = 1;
$result = $mail->Send();
echo 'Sent';
} catch (phpmailerException $e) {
echo $e->errorMessage();
}
?>
我得到Sent
因为没有错误,但在我的雅虎帐户中我没有收到任何内容。