添付ファイルが生成され、mail() で送信されたメールに問題があります。hereの例 3 を使用します。
そして、それはうまくいきます。しかし、いくつかの php 定義 ($somthing = $_POST['sth'] など) を追加すると、届いた電子メールはフォーマットされておらず、ソース コードのように見えます。
<?php
//session_start();
include('funkcje.php');
//$db=polaczMy();
$nazwa = uzupelnij($_POST['nazwa']);
$vorname= uzupelnij($_POST['vorname']);
$strasse = uzupelnij($_POST['strasse']);
$kod = uzupelnij($_POST['kod']);
$tel = uzupelnij($_POST['tel']);
$mail = uzupelnij($_POST['mail']);
$datum_od = uzupelnij($_POST['datum_od']);
$datum_to = uzupelnij($_POST['datum_to']);
$ort = uzupelnij($_POST['ort']);
$zeit = uzupelnij($_POST['zeit']);
$mietteilung = uzupelnij($_POST['mietteilung']);
$service = uzupelnij($_POST['service']);
function uzupelnij($przesyl){
if(empty($przesyl)){
$przesyl = "";
return $przesyl;
}
}
$to = '***@***.net';
$subject = 'Anfrage';
$random_hash = md5(date('r', time()));
$headers = "From: ***@***.de\r\n";
$headers .= "\r\nContent-Type: multipart/mixed; boundary=\"PHP-mixed-".$random_hash."\"";
$attachment = "BEGIN:VCARD\nVERSION:3.0\nN:".$vorname.";;;;\nFN:".$vorname."\nORG:".$nazwa."\nADR;TYPE=work:;;".$strasse.";".$ort.";;;\nEMAIL;type=INTERNET;type=WORK;type=internet:".$mail."\nTEL;type=WORK;type=pref:".$tel."\nEND:VCARD";
ob_start();
?>
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: multipart/alternative; boundary="PHP-alt-<?php echo $random_hash; ?>"
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-<?php echo $random_hash; ?>
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-<?php echo $random_hash; ?>--
--PHP-mixed-<?php echo $random_hash; ?>
Content-Type: text/vcard; name="attachment.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment
<?php echo $attachment; ?>
--PHP-mixed-<?php echo $random_hash; ?>--
<?php
//copy current buffer contents into $message variable and delete current output buffer
$message = ob_get_clean();
//send the email
$mail_sent = @mail( $to, $subject, $message, $headers );
//if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"
echo $mail_sent ? "<span style=\"margin-top: 20px; font-size: 18px; font-weight: bold;\">Vielen Dank! Ihre Anfrage wurde versendet. Wir werden bald mit Ihnen Kontakt aufnehmen. </span>" : "Mail failed";
//session_destroy();
// }
?>
そしてメールで:
Content-Type: multipart/mixed; boundary="PHP-mixed-26680626f5767c87be4bc162d5e80e8e"
--PHP-mixed-26680626f5767c87be4bc162d5e80e8e
Content-Type: multipart/alternative; boundary="PHP-alt-26680626f5767c87be4bc162d5e80e8e"
--PHP-alt-26680626f5767c87be4bc162d5e80e8e
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Hello World!!!
This is simple text email message.
--PHP-alt-26680626f5767c87be4bc162d5e80e8e
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<h2>Hello World!</h2>
<p>This is something with <b>HTML</b> formatting.</p>
--PHP-alt-26680626f5767c87be4bc162d5e80e8e--
--PHP-mixed-26680626f5767c87be4bc162d5e80e8e
Content-Type: text/vcard; name="attachment.vcf"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment
BEGIN:VCARD
VERSION:3.0
N:dgsdg;;;;
FN:dgsdg
ORG:bgdfg
ADR;TYPE=work:;;dgsdg;gdsg;;;
EMAIL;type=INTERNET;type=WORK;type=internet:gsdgdf
TEL;type=WORK;type=pref:gfgs
END:VCARD
--PHP-mixed-26680626f5767c87be4bc162d5e80e8e--