邮件没有使用PHP接收

时间:2012-04-09 06:17:09

标签: php email

这是我的邮寄代码:

   <?php
error_reporting(E_ALL);
$user_subject = "Ticket - Budget Notification";
$user_headers = "From: mariyadavis90@gmail.com\r\n";
$user_headers .= "MIME-Version: 1.0\r\n";
$user_headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$user_part = '<html><body>';
$user_part .= '<div style="background-color: #EEEEEE;border-bottom: 1px solid #DCDCDC;padding: 10px 10px 20px;width: 500px; float:left;font-size:12px;font-weight:bold;">';
$user_part1 = '<div style="width:500px;">';
$user_part1 .= '<div style="width:500px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">';
$user_part1 .= '<div style="float:left;width:150px;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;">';
$user_part1 .= '</div></div>';
$user_part1 .= '<div style="width:450px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc; height:auto; float:left;font-size:12px;margin-left:50px; font-weight:bold;">';
$user_part3 = '</div></div></div>';
$user_part3 .= '</body></html>';
$user_center_part1 = '';    
$user_center_part = 'The following Tickets are reached its budget ,';   
$user_center_part2='<div style="float:left;width:auto;color:#000000;font-size:12px;margin-left:75px; font-weight:bold; height:auto; margin-top:10px;">Ticket #10 reached 100% of its budget</div>';
$user_to = 'galtech.staffs@gmail.com';
if($user_to){

        $user_center_part1 = 'Dear Admin ,';
        $user_message = $user_part.$user_center_part1.$user_part1.$user_center_part.$user_center_part2.$user_part3; 
        if(mail($user_to, $user_subject, $user_message, $user_headers))
        {
            echo "Mail Send Successfully";
        }else{
            echo "Mail Not Send Successfully";
        }
    }
?>

当我使用此邮寄代码时,我无法在帐户中收到任何邮件。我的代码有什么问题?帐户中不会收到任何内容。它每次都显示Mail Sent Successfully

2 个答案:

答案 0 :(得分:1)

您的From:标题看起来很糟糕,大多数邮件服务器都会高兴地拒绝您的电子邮件,因为这样的邮件无效。请确保它包含实际的电子邮件地址,然后重试。

答案 1 :(得分:0)

我注意到您收到的电子邮件是gmail,即; &#39; galtech.staffs@gmail.com' 我使用你的脚本进行测试,我收到邮件,但作为垃圾邮件。我相信你也收到它们,php邮件功能使用gmail作为收件人电子邮件创建问题,编辑标题部分之后的任何方式我收到邮件在我的收件箱中,这里是结果;

this is what you looking for

试试这个;

$user_subject = "Ticket - Budget Notification";
$user_headers = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$user_part = '<html><body>';
$user_part .= '<div style="background-color: #EEEEEE;border-bottom: 1px solid #DCDCDC;padding: 10px 10px 20px;width: 500px; float:left;font-size:12px;font-weight:bold;">';
$user_part1 = '<div style="width:500px;">';
$user_part1 .= '<div style="width:500px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc;">';
$user_part1 .= '<div style="float:left;width:150px;color:#666666;margin-left:20px;font-size:12px;font-weight:bold;">';
$user_part1 .= '</div></div>';
$user_part1 .= '<div style="width:450px;background-color:#eeeeee;padding: 10px 0 20px;border-bottom:1px solid #dcdcdc; height:auto; float:left;font-size:12px;margin-left:50px; font-weight:bold;">';
$user_part3 = '</div></div></div>';
$user_part3 .= '</body></html>';
$user_center_part1 = '';    
$user_center_part = 'The following Tickets are reached its budget ,';   
$user_center_part2='<div style="float:left;width:auto;color:#000000;font-size:12px;margin-left:75px; font-weight:bold; height:auto; margin-top:10px;">Ticket #10 reached 100% of its budget</div>';

$user_to = 'youremailid@gmail.com';

       $user_center_part1 = 'Dear Admin ,';
       $user_message = $user_part.$user_center_part1.$user_part1.$user_center_part.$user_center_part2.$user_part3; 
        if(mail($user_to, $user_subject, $user_message, $user_headers))

            echo "Mail Send Successfully";
        else
            echo "Mail Not Send Successfully";