带有附件的PHP邮件没有错误

带有附件的PHP邮件没有错误,php,Php,我的web服务器支持mail()函数。我没有看到任何错误。但是我的邮件没有收到邮件。我在so和Google上尝试了很多东西 <?php //error_reporting(-1); //ini_set('display_errors', 'On'); //set_error_handler("var_dump"); $to = "raveen_chandra@yahoo.com"; $subject = "New attachment m

我的web服务器支持mail()函数。我没有看到任何错误。但是我的邮件没有收到邮件。我在so和Google上尝试了很多东西

     <?php
    //error_reporting(-1);
    //ini_set('display_errors', 'On');
    //set_error_handler("var_dump");

    $to = "raveen_chandra@yahoo.com";
    $subject = "New attachment message";

    $msg = "This is headline";
    $message .= "This is my first line of text.\nThis is my second line of text";

    $fileatt = "uploads/3.JPG";
    $fo = fopen( $fileatt, 'r' );
    $data = fread( $fo, filesize($fileatt) ); //read entire file
    fclose( $fo );
    $data = chunk_split( base64_encode($data) ); //?????? what is chunk_split and base64_encode

    //generate a boundary
    $uid = md5(uniqid(time())); //md5() is used to create unique number
    $filename = basename( $fileatt );

    //main header (multipart mandatory)
    $header = "From: Raveen Chandra <raveen1231@gmail.com> \r\n";
    //$header .= "Cc: raveen749@gmail.com \r\n";
    //$header .= "Bcc: raveen678@gmail.com \r\n";
    //$header .= "Reply-to: raveen_chandra@yahoo.com \r\n"; //can be same address as From header or other
    $header .= "MIME-Version: 1.0 \r\n";
    $header .= "Content-type: multipart/mixed; boundary=\"". $uid. "\"\r\n"; //to send an email with attachment, we need to use the multipart/mixed MIME type
                                             //it specifies that mixed types will be included in the email

    /* message and attachment - message and attachment sections can be specified within boundaries.
    */
    $message = "--". $uid. "\r\n"; //boundary starts with two hyphens, followed by a unique number 
    $message .= "Content-type: text/plain; charset=iso-8859-1\r\n"; //Content-type: text/plain;
    $message .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $message .= $msg. "\r\n\r\n";
    $message .= "--". $uid. "\r\n"; //When sending multiple attachments, separate MIME parts with this
    $message .= "Content-type: image/jpeg; name\"". $filename. "\"\r\n"; //use different content types here
    $message .= "Content-Transfer-Encoding: base64\r\n";
    $message .= "Content-Disposition: attachment; filename=\"". $filename. "\"\r\n\r\n";
    $message .= $data. "\r\n\r\n";
    $message .= "--". $uid. "--"; //after the final MIME part

    if( mail($to, $subject, $message, $header) ){
        echo "Message sent successfully";
    }
    else{
        echo "Message could not be sent!";
    }
?>

您可以签入垃圾邮件

请提供您的信息

$to=“拉文_chandra@yahoo.com"; //这是错误的方式。 $to=”mymail@yahoo.com"; //很好
方式。

取消注释前三行,检查您得到的错误是什么
error\u reporting(E\u ALL);ini设置(“显示错误”,1)@Uchiha,长官,我没有检查。然后我得到了很多错误,充满了难以阅读的页面。有一件事。。。int(8)字符串(27)“未定义变量:消息”字符串(33)。然后我更正:)然后我就没有错误了。但我还是没有收到我不明白的电子邮件。很抱歉我在干什么?请告诉我