PHP MAIL电子邮件正文未包含在内

时间:2018-11-29 18:35:01

标签: php

我有一个脚本可以通过电子邮件发送附件,但是我无法接收包含在其中的电子邮件,而只是发送空白

我尝试了不同的字符集,UTF8和ISO8559

我尝试过

"Content-Type: text/html; charset=\"utf-8\n" . 

"Content-Type: text/plaintext; charset=\"utf-8\n" .

但没有区别....

$name        = "XXXXXXXX";
$email       = "XXXXXX";
$to          = "XXXXXXXXX";
$from        = "XXXXXXXX";
        $subject     = "Thank you for your payment";
    $mainMessage = "ANy text here to send in email";
    $fileatt     = "inv/".$invRef.".pdf";
    $fileatttype = "application/pdf";
    $fileattname = $invRef.".pdf";
    $headers = "From: $from";



    // File
    $file = fopen($fileatt, 'rb');
    $data = fread($file, filesize($fileatt));
    fclose($file);
    // This attaches the file
$semi_rand     = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers      .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

$message = "" .
"-{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"utf-8\n" .
"Content-Transfer-Encoding: 7bit\n" .
$mainMessage  . "\n";

$data = chunk_split(base64_encode($data));
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileattname}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileattname}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"-{$mime_boundary}-\n";

我尝试了其他邮件处理程序,例如快速简单的外部库,但由于其他原因,它们使我更加头疼

这使我最接近发送电子邮件

附件有效,电子邮件发送,主题很好。

体内什么也没有

0 个答案:

没有答案