PhP邮件函数返回true,但邮件未送达
我有一个域名PhP邮件函数返回true,但邮件未送达,php,email,Php,Email,我有一个域名www.ipsmeerut.com,我正在使用下面的脚本发送邮件。返回true,但邮件未发送 这是我的剧本: <?php $to = 'brajnacs@gmail.com'; $subject = 'Test'; $headers = "From: Test<no-reply@ipsmeerut.com>\n"; $headers .= "MIME-Version: 1.0\n"; $headers .= "Cont
www.ipsmeerut.com
,我正在使用下面的脚本发送邮件。返回true,但邮件未发送
这是我的剧本:
<?php
$to = 'brajnacs@gmail.com';
$subject = 'Test';
$headers = "From: Test<no-reply@ipsmeerut.com>\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
$message = "<html><body>";
$message .= "<h1>Hello, World!</h1>";
$message .= "</body></html>";
$res=false;
$res=mail($to, $subject, $message, $headers);
var_dump($res);
echo "Mail sent to ".$to;
?>
此脚本在我的其他域上运行良好<代码>变量转储正在显示
true
。我的邮件服务器是aspmx.l.google.com
,我还为它添加了MX条目。使用phpmailer,试试这个
require_once('../class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = 'you content goes here';
$body = eregi_replace("[\]",'',$body);
$mail->AddReplyTo("name@yourdomain.com","First Last");
$mail->SetFrom('name@yourdomain.com', 'First Last');
$mail->AddReplyTo("name@yourdomain.com","First Last");
$address = "whoto@otherdomain.com";
$mail->AddAddress($address, "John Doe");
$mail->Subject = "PHPMailer Test Subject via mail(), basic";
$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!";
}
为什么不使用默认MX并再次尝试测试?Google允许发送带有身份验证的匿名电子邮件吗?我觉得PHP mailer有点粗糙,你试过使用PHP mailer吗?可能有助于与google mail进行交互。最好不要使用mail()
。请看:是的,先生,我使用的phpmailer类在返回True时也不起作用,我只是一个新手。请告诉我如何知道我们的默认MXit your domain.com(ipsmeerut.com)将google MX更改为默认值。