使用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.

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();