使用PHP将电子邮件中的HTML表单输入作为PDF附件发送[关闭]

问题描述:

I would like to create a form that takes basic input from a user. I would like to send this data in the form of a PDF document to another user through an email.

  • The user gives some input values in the form
  • Once the user submits the form, the data should be converted to PDF and should be emailed to the administrator

I wanted to find out if there is a way to accomplish this without storing the file on the server.

我想创建一个从用户那里获取基本输入的表单。 我想通过电子邮件将这些数据以PDF文档的形式发送给其他用户。 p>

  • 用户以 li>
  • 的形式提供一些输入值。一旦用户提交表单,数据应转换为PDF并且应该 通过电子邮件发送给管理员 li> ul>

    我想知道是否有办法在不将文件存储在服务器上的情况下完成此任务。 p>

I got the answer: You can use PHPMailer to do this. The code looks somewhat like this:

$mail = new PHPMailer(); 
...
$doc = $pdf->Output('', 'S'); 
$mail->AddStringAttachment($doc, 'doc.pdf', 'base64', 'application/pdf'); 
$mail->Send();