简体   繁体   English

使用FPDF调整邮件中的字体和字体大小

[英]Adjust type font and font size in mail with FPDF

I need your help! 我需要你的帮助!

I have some file that generates a mail with attachment in FPDF and what I need is configure the font family for the mail to Arial and Size 12px, I know how to do that in the PDF but not in the mail. 我有一些文件会在FPDF中生成带有附件的邮件,我需要将邮件的字体系列配置为Arial和Size 12px,我知道如何在PDF中而不是在邮件中这样做。

This is the code for mail with FPDF 这是FPDF邮件的代码

$filename = "example.pdf";
// encode data (puts attachment in proper format)
$pdfdoc = $pdf->Output("", "S");
$attachment = chunk_split(base64_encode($pdfdoc));

// main header (multipart mandatory)
$headers  = "From: ".$from.$eol;
$headers .= "MIME-Version: 1.0".$eol; 
$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; 
$headers .= "Content-Transfer-Encoding: 7bit".$eol;
$headers .= "This is a MIME encoded message.".$eol.$eol;
// message
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$headers .= $message.$eol.$eol;
// attachment
$headers .= "--".$separator.$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol; 
$headers .= "Content-Transfer-Encoding: base64".$eol;
$headers .= "Content-Disposition: attachment".$eol.$eol;
$headers .= $attachment.$eol.$eol;
$headers .= "--".$separator."--";
// send message
mail($to, $subject, "", $headers);

I hope you can help me, thanks ! 希望您能帮助我,谢谢!

Email needs to use inline styling, along the following lines: 电子邮件需要使用内联样式,包括以下几行:

<p style="font-family: Arial, sans-serif; font-size: 12px">This paragraph is formatted correctly</p>

Or you could put the style into a 或者您可以将样式放入

<span>Here is lots of stuff.</span> 

tag covering the relevant portions inside the 标签覆盖了内部的相关部分

<body></body> 

of the email. 电子邮件。

I'm not sure why you are not putting $message as the third arg to mail() function. 我不确定为什么不将$ message用作mail()函数的第三个参数。 In any case, you will need to play with its content. 无论如何,您都需要使用其内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM