【问题标题】:Adjust type font and font size in mail with FPDF使用 FPDF 调整邮件中的字体和字体大小
【发布时间】:2014-10-22 01:53:21
【问题描述】:

我需要你的帮助!

我有一些文件在 FPDF 中生成带有附件的邮件,我需要将邮件的字体系列配置为 Arial 和大小 12px,我知道如何在 PDF 中执行此操作,但在邮件中不知道。

这是 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);

希望你能帮助我,谢谢!

【问题讨论】:

    标签: php html email fpdf


    【解决方案1】:

    电子邮件需要使用内联样式,大致如下:

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

    或者你可以把样式放到一个

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

    标签覆盖了

    里面的相关部分
    <body></body> 
    

    电子邮件。

    我不确定你为什么不把 $message 作为第三个参数放到 mail() 函数中。在任何情况下,您都需要使用它的内容。

    【讨论】:

      猜你喜欢
      • 2012-09-18
      • 2019-04-09
      • 2023-03-09
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多