1

PHP でメールに添付ファイルを送信しています。順調です。しかし、私はユーザーの詳細を送信したいと考えています。詳細は、メッセージではなく HTML で印刷されます。

$my_file = 'attach.txt';
$my_path = "path/".$file_name;
$my_name = "noreply@mail.com ";
$my_mail = "noreply@mail.com";
$my_replyto = "noreply@mail.net";
$my_subject = "test E-Mail";
$my_message = htmlspecialchars_decode("<html><body><center><table width='400px' height='400px'><th>career</th><tr><td>Name</td><td>My name</td></tr><tr><td>Email</td><td>My Email</td></tr><tr><td>Post</td><td>My Post</td></tr><tr><td>Address</td><td>My Address</td></tr></table> </center><br><br></body></html>");

$mailto = "myemail@gmail.com";
$content = chunk_split(base64_encode(file_get_contents($my_path)));
$uid = md5(uniqid(time()));
$name = basename($my_path);
$header = "From: ".$my_mail."\r\n";
$header .= "Reply-To: ".$my_replyto."\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
$header .= "This is a multi-part message in MIME format.\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
$header .= $my_message."\r\n\r\n";
$header .= "--".$uid."\r\n";
$header .= "Content-Type: application/octet-stream; name=\"".$my_file."\"\r\n"; 
// use different content types here
$header .= "Content-Transfer-Encoding: base64\r\n";
$header .= "Content-Disposition: attachment; filename=\"".$my_file."\"\r\n\r\n";
$header .= $content."\r\n\r\n";
$header .= "--".$uid."--";

if (mail($mailto, $my_subject, '', $header)) {
echo "email send";
exit;
} else {
echo "Error during mail send.!";
exit;
}
4

1 に答える 1

2

変化する

$header .= "Content-type:text/plain; charset=iso-8859-1\r\n";

$header .= "Content-type:text/html; charset=iso-8859-1\r\n";
于 2013-03-29T16:48:01.260 に答える