Smtp phpmailer成功,但未发送电子邮件
PHPMailer说成功了,但是没有发送电子邮件。电子邮件跟踪未显示任何错误。从发送或接收电子邮件。有什么我遗漏的吗 下面是我的mailer.php文件:Smtp phpmailer成功,但未发送电子邮件,smtp,phpmailer,Smtp,Phpmailer,PHPMailer说成功了,但是没有发送电子邮件。电子邮件跟踪未显示任何错误。从发送或接收电子邮件。有什么我遗漏的吗 下面是我的mailer.php文件: require 'class.phpmailer.php'; require 'class.smtp.php'; $mail = new PHPMailer; $mail->isSMTP(); // Set mailer to use SMTP $m
require 'class.phpmailer.php';
require 'class.smtp.php';
$mail = new PHPMailer;
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'localhost'; // Specify main and backup server
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'diane@example.com'; // SMTP username: FROM EMAIL
$mail->Password = 'pw'; // SMTP password: FROM PW
$mail->From = 'diane@example.com'; //FROM EMAIL
$mail->addAddress('terry@example.com'); // Add a recipient, Name is optional
$mail->WordWrap = 50; // Set word wrap to 50 characters
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Contact Form';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
if(!$mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $mail->ErrorInfo;
exit;
}
echo 'Message has been sent';
我不知道你为什么用这种方法用PHP发送电子邮件。这里有一个更好的方法来实现这一点:
$to = 'test@test.com';
$subject = 'Lorem Ipsum';
$from = 'me@me.com';
$message = 'Congrats! You won! Message body here.';
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
显然,此人需要能够使用SMTP身份验证发送电子邮件,因此您的基本解决方案肯定不会帮助他们。