PHP 5.4.30 mail()函数为Gmail / yahoo电子邮件ID提供服务器未找到错误

时间:2014-09-01 07:45:58

标签: php

我已将服务器 php版本升级到5.4.30

当我在此版本中使用 mail()时,它会将邮件发送到其他邮件ID,例如我公司的网络邮件,但当我使用 Gmail / yahoo电子邮件时,它无法发送电子邮件并提供 500内部服务器错误

代码

<?php
$arr = array('myemail@company.com','myemail@gmail.com');
foreach($arr AS $key => $value)
{
    $to = $value;
    $subject = "Test Mail";
    $message = "<p>TEST</p>";

    $from = "senderemail@gmail.com";    
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=UTF-8\r\n";
    $headers .= "From: <".$from.">" ;
    mail($to, $subject, $message, $headers);
    //  It send mail to myemail@company.com this id
    // but for gmail id it shows error
}
?>

2 个答案:

答案 0 :(得分:0)

我从服务器端更改了一些设置..我将我的网站ip添加到连接器的服务器设置中,它再次像魅力一样工作并保存我的头发..

答案 1 :(得分:-3)

<?php
ob_start();
$arr = array('myemail@company.com','myemail@gmail.com');
foreach($arr AS $key => $value)
{
    $to = $value;
    $subject = "Test Mail";
    $message = "<p>TEST</p>";

    $from = "senderemail@gmail.com";    
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=UTF-8\r\n";
    $headers .= "From: <".$from.">" ;
    mail($to, $subject, $message, $headers);
    ob_flush();
}
ob_end_flush();
?>