附件但没有文字php电子邮件?

时间:2014-04-03 23:55:55

标签: php

我正在为一个网站制作一段代码,并制作了以下代码,但是我需要在电子邮件中加入html,但是它没有发送它,它只附加图片,请帮忙吗?

<?php 
$emailSubject = 'Application - '.$_POST['full_name'].'';
$webMaster = 'email@webaddress.com';
$from = $_POST["email"];

$tmpName = $_FILES['attachment']['tmp_name']; 
$fileType = $_FILES['attachment']['type']; 
$fileName = $_FILES['attachment']['name']; 

$headers = "From: $fromName"; 

if (file($tmpName)) { 
    $file = fopen($tmpName,'rb'); 
    $data = fread($file,filesize($tmpName)); 
    fclose($file); 
    $randomVal = md5(time()); 
    $mimeBoundary = "==Multipart_Boundary_x{$randomVal}x"; 
    $headers .= "\nMIME-Version: 1.0\n"; 
    $headers .= "Content-Type: multipart/mixed;\n" ;
    $headers .= " boundary=\"{$mimeBoundary}\""; 
    $message = "This is a multi-part message in MIME format.\n\n" . 
    "--{$mimeBoundary}\n" . 
    "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . 
    "Content-Transfer-Encoding: 7bit\n\n" . 
    $message . "\n\n"; 
    $data = chunk_split(base64_encode($data)); 
    $message .= "--{$mimeBoundary}\n" . 
    "Content-Type: {$fileType};\n" . 
    " name=\"{$fileName}\"\n" . 
    "Content-Transfer-Encoding: base64\n\n" . 
    $data . "\n\n" . 
    "--{$mimeBoundary}--\n"; 
} 

$html_message = "<html>"

$email_message = mail($webMaster, $emailSubject, $message, $headers);

$result = 'Result Code Here On Page';

echo "$result";

?>

0 个答案:

没有答案