Php 带有生成的附件的邮件()不是';t在客户端邮件上格式化
我对生成附件并通过mail()发送的邮件有问题。 我使用来自的示例3 而且效果很好。但是当我添加一些php定义时(比如:$somthing=$\u POST['sth']),收到的电子邮件没有格式化,看起来像源代码Php 带有生成的附件的邮件()不是';t在客户端邮件上格式化,php,Php,我对生成附件并通过mail()发送的邮件有问题。 我使用来自的示例3 而且效果很好。但是当我添加一些php定义时(比如:$somthing=$\u POST['sth']),收到的电子邮件没有格式化,看起来像源代码 <?php //session_start(); include('funkcje.php'); //$db=polaczMy(); $nazwa = uzupelnij($_POST['nazwa']); $vorname= uzupe
<?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();
// }
?>
--PHP混合-
内容类型:多部分/备选;boundary=“PHP alt-”
--PHP alt-
内容类型:文本/纯文本;charset=“iso-8859-1”
内容传输编码:7bit
你好,世界!!!
这是一封简单的短信。
--PHP alt-
内容类型:text/html;charset=“iso-8859-1”
内容传输编码:7bit
你好,世界!
这是HTML格式的东西。
--PHP alt--
--PHP混合-
内容类型:文本/vcard;name=“附件.vcf”
内容传输编码:7bit
内容配置:附件
--PHP混合--
邮寄:
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--
内容类型:多部分/混合;boundary=“PHP-mixed-26680626f5767c87be4bc162d5e80e8e”
--PHP-mixed-26680626f5767c87be4bc162d5e80e8e
内容类型:多部分/备选;boundary=“PHP-alt-26680626f5767c87be4bc162d5e80e8e”
--PHP-alt-26680626f5767c87be4bc162d5e80e8e
内容类型:文本/纯文本;charset=“iso-8859-1”
内容传输编码:7bit
你好,世界!!!
这是一封简单的短信。
--PHP-alt-26680626f5767c87be4bc162d5e80e8e
内容类型:text/html;charset=“iso-8859-1”
内容传输编码:7bit
你好,世界!
这是HTML格式的东西。
--PHP-alt-26680626f5767c87be4bc162d5e80e8e--
--PHP-mixed-26680626f5767c87be4bc162d5e80e8e
内容类型:文本/vcard;name=“附件.vcf”
内容传输编码:7bit
内容配置:附件
开始:VCARD
版本:3.0
N:dgsdg;;;;
FN:dgsdg
组织:bgdfg
药品不良反应;类型=工作:;;dgsdg;gdsg;;;
电子邮件;类型=互联网;类型=工作;类型=互联网:gsdgdf
电话;类型=工作;类型=首选项:gfgs
完:VCARD
--PHP-mixed-26680626f5767c87be4bc162d5e80e8e--
这将导致标题中出现空行,因此标题将在From
字段结束,内容类型将被视为消息正文
在每个边界标记之前还缺少一条空行
更重要的是:
function uzupelnij($przesyl){
if(empty($przesyl)){
$przesyl = "";
return $przesyl;
}
}
你认为它有什么作用?它返回null或空字符串,因此从POST数据分配的每个变量都是空的。您编辑了代码的哪一部分?内容类型标题似乎已附加到正文中。请不要生成自己的mime电子邮件。这太痛苦/难看了。使用phpmailer或swiftmailer,将所有代码减少到大约5行。
function uzupelnij($przesyl){
if(empty($przesyl)){
$przesyl = "";
return $przesyl;
}
}