0

我是 php 新手,并且在构建页面时一直在学习。我当前的任务是能够在浏览器中打开 PDF,填写表单,然后单击表单底部的按钮提交表单。

我们希望发送完整的表格,而无需将副本保存到服务器。不过,拥有两种形式的循环并不可怕。

我目前可以发送电子邮件,但脚本只发送空白文档。

<?php

require("class.phpmailer.php");

$mail = new PHPMailer();

$mail->IsSMTP();  // telling the class to use SMTP
$mail->Host     = "xxx.xxx.xxx"; // SMTP server

$mail->From     = "xxx@xxx.xxx";
$mail->AddAddress("xxx@xxx.xxx");

$mail->Subject  = "Attachment Test";
$mail->Body     = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
$mail->WordWrap = 50;
$mail->AddAttachment('tshirtorderform.pdf');

if(!$mail->Send()) {
  echo 'Message was not sent.';
  echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
  echo 'Message has been sent.';
}
?>

我意识到我是在告诉它检索空白文档,但我对如何附加已完成的表格一无所知。

谢谢。

4

2 回答 2

2

PHPmailer 中有一个半未记录的 AddStringAttachment() 方法,它允许您直接从字符串附加,而不需要实际的磁盘文件:

http://phpmailer.worxware.com/index.php?pg=tutorial

搜索“字符串附件”。打败我为什么他们没有在方法文档中列出。

于 2013-02-19T15:01:18.020 回答
0

我也推荐了 AddStringAttachment() 方法,但首先你需要使用 TCPDF 来创建 PDF 的正文。

我在这个主题中给出了一些提示:AddStringAttachment with PDF in PHPMailer not work

于 2014-05-20T17:26:12.783 回答