Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 我想通过电子邮件发送一份PDF,作为使用FPDF创建的附件。但这种依恋从未实现_Php_Sql_Email_Fpdf - Fatal编程技术网

Php 我想通过电子邮件发送一份PDF,作为使用FPDF创建的附件。但这种依恋从未实现

Php 我想通过电子邮件发送一份PDF,作为使用FPDF创建的附件。但这种依恋从未实现,php,sql,email,fpdf,Php,Sql,Email,Fpdf,我已经编写了下面的代码来生成pdf,并且生成的pdf很好并显示出来,然后在第二部分中,我编写了代码来自动生成邮件并发送,但没有响应。。建议? 提前感谢:) 发现解决方案及其工作状态非常好,请按以下方式更改上述代码 // email stuff (change data below) $to = "saxxxx@gmail.com"; $from = "aneexxxxx@gmail.com"; $subject = "Patient detials with pdf attachment

我已经编写了下面的代码来生成pdf,并且生成的pdf很好并显示出来,然后在第二部分中,我编写了代码来自动生成邮件并发送,但没有响应。。建议? 提前感谢:)


发现解决方案及其工作状态非常好,请按以下方式更改上述代码

  // email stuff (change data below)
$to = "saxxxx@gmail.com"; 
$from = "aneexxxxx@gmail.com"; 
$subject = "Patient detials with pdf attachment"; 
$message = "<p>Please see the attachment.</p>";

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = "patientdetials.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;

//NOTICE I changed $headers to $body!!

$body .= "Content-Transfer-Encoding: 7bit".$eol;
$body .= "This is a MIME encoded message.".$eol; //had one more .$eol

// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol; //had one more .$eol

// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--";

// send message NOTICE I replaced "" with $body
mail($to, $subject, $body, $headers);
?>
//电子邮件内容(更改下面的数据)
$to=”saxxxx@gmail.com"; 
$from=”aneexxxxx@gmail.com"; 
$subject=“带pdf附件的患者详细信息”;
$message=“请参阅附件。

”; //发送混合内容时需要随机散列 $separator=md5(time()); //回车类型(我们使用一个PHP行尾常量) $eol=PHP\u eol; //附件名称 $filename=“patientdetials.pdf”; //对数据进行编码(以正确的格式放置附件) $pdfdoc=$pdf->输出(“,”S”); $attachment=chunk_split(base64_encode($pdfdoc)); //主标题(多部分必填) $headers=“From:”.$From.$eol; $headers.=“MIME版本:1.0”。$eol; $headers.=“内容类型:多部分/混合;边界=\”“.$separator.\”“.$eol.$eol; //注意,我将$headers更改为$body!! $body.=“内容传输编码:7bit”。$eol; $body.=“这是一条MIME编码的消息。”。$eol//还有一个。$eol //信息 $body.=“-”$separator.$eol; $body.=“内容类型:文本/html;字符集=\“iso-8859-1\”。$eol; $body.=“内容传输编码:8位”。$eol.$eol; $body.=$message.$eol//还有一个。$eol //附件: $body.=“-”$separator.$eol; $body.=“内容类型:应用程序/八位字节流;名称=\”“.$filename.\”“.$eol; $body.=“内容传输编码:base64”。$eol; $body.=“内容处置:附件”。$eol.$eol; $body.=$attachment.$eol; $body.=“--”“分隔符”“--”; //发送消息通知我将“”替换为$body 邮件($to、$subject、$body、$headers); ?>
或使用助手类创建带有附件的电子邮件,如我所写的
  // email stuff (change data below)
$to = "saxxxx@gmail.com"; 
$from = "aneexxxxx@gmail.com"; 
$subject = "Patient detials with pdf attachment"; 
$message = "<p>Please see the attachment.</p>";

// a random hash will be necessary to send mixed content
$separator = md5(time());

// carriage return type (we use a PHP end of line constant)
$eol = PHP_EOL;

// attachment name
$filename = "patientdetials.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;

//NOTICE I changed $headers to $body!!

$body .= "Content-Transfer-Encoding: 7bit".$eol;
$body .= "This is a MIME encoded message.".$eol; //had one more .$eol

// message
$body .= "--".$separator.$eol;
$body .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
$body .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
$body .= $message.$eol; //had one more .$eol

// attachment
$body .= "--".$separator.$eol;
$body .= "Content-Type: application/octet-stream; name=\"".$filename."\"".$eol;
$body .= "Content-Transfer-Encoding: base64".$eol;
$body .= "Content-Disposition: attachment".$eol.$eol;
$body .= $attachment.$eol;
$body .= "--".$separator."--";

// send message NOTICE I replaced "" with $body
mail($to, $subject, $body, $headers);
?>