1

My company is currently trying to streamline our process for submitting forms. I have read that what we are trying to do can be done with PHP or PHPMailer but I seem to have hit a roadblock.

What we are trying to do is open a fillable PDF in browser, complete it, and then click a button at the bottom to email it to a designated recipient.

I currently have a PHP script that allows me to email the blank document using PHPMailer and our server email service.

I have tried using the "AddStringAttachment" feature of PHPMailer:

<?php

require("../PHPMailer_5.2.3/class.phpmailer.php");

$mail = new PHPMailer();

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

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

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

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

...but I was unable to find a way to define the string in a way that would send the completed form. Currently, if I put any data into the "$string" field the email fails.

Is this even possible? Or am I just spinning my wheels?

4

1 回答 1

0

问题可能出在您的邮件服务器上。许多服务器不喜欢发送损坏的 PDF,这将是任何看起来不像普通 PDF 的 PDF - 例如,一串英文文本。

在我开始讨论如何在 PHP 中生成 PDF 之前,您是否可以发送任何其他类型的附件?

于 2013-02-19T21:03:46.503 回答