0

这是我的邮寄代码:

   <?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每次都会显示。

4

2 回答 2

1

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

于 2012-04-09T06:27:33.763 回答
0

我注意到您的接收电子邮件是 gmail,也就是说;'galtech.staffs@gmail.com' 我将您的脚本用于测试目的,我收到了邮件,但作为垃圾邮件。我相信您也收到了它们,php 邮件功能使用 gmail 作为接收者电子邮件会产生问题,在编辑标题部分后我会在收件箱中收到邮件,这是结果;

这就是你要找的

尝试这个;

$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";
于 2012-04-09T14:14:29.747 回答