我有一个简单的联系表单,它使用PHPMailer将其信息发送给管理员。当结果被发送到没有诸如blah@blah.com之类的超级电子邮件时,一切正常。一旦我将地址更改为发送电子邮件如blah@blah-blah.com,我就会收到此错误。
“无法实例化邮件功能。邮件程序错误:无法实例化邮件功能。”
这是PHPMailer的错误吗?
这是我的代码
<?php
require_once('class.phpmailer.php');
$question_for = $_POST['question_for'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$company = $_POST['company'];
$comment = $_POST['comment'];
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("donotreply@blah-blah.com","DoNotReply");
$mail->SetFrom('donotreply@blah-blah.com', 'DoNotReply');
switch ($question_for) {
case "Sales":
$address = "Sales@blah-blah.com";
$mail->AddAddress($address, "Blah");
$mail->Subject = "Message from Sales";
break;
case "Service":
$address = "service@blah-blah.com";
$mail->AddAddress($address, "Blah");
$mail->Subject = "Message from Service";
break;
case "Career":
$address = "career@blah-blah.com";
$mail->AddAddress($address, "Blah");
$mail->Subject = "Message from Career";
break;
}
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML("
Question For:".$question_for."<br />
Name:".$name."<br />
Phone:".$phone."<br />
Email:".$email."<br />
Company:".$company."<br />
Comment:".$comment."<br />");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
header('Location: http://blah.com/contact/?sent');
}
?>
检查更多,我看到这有效
<?php
mail("test@blah.com", "Test Email", "Testing"); ?>
但这不是
<?php
mail("test@blah-blah.com", "Test Email", "Testing"); ?>