使用PHP或PHPMailer通过电子邮件填充PDF [英] Email filled PDF with PHP or PHPMailer

查看:125
本文介绍了使用PHP或PHPMailer通过电子邮件填充PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的公司目前正在尝试简化我们的表单提交流程.我已经读到我们想做的事情可以用PHP或PHPMailer来完成,但是我似乎遇到了障碍.

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.

我们要做的是在浏览器中打开可填充的PDF,完成该操作,然后单击底部的按钮,将其通过电子邮件发送给指定的收件人.

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.

我目前有一个PHP脚本,该脚本允许我使用PHPMailer和我们的服务器电子邮件服务通过电子邮件发送空白文档.

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

我尝试使用PHPMailer的"AddStringAttachment"功能:

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.';
}
?>

...但是我无法找到一种方法来定义字符串,从而无法发送完成的表格.当前,如果我将任何数据放入"$ string"字段中,电子邮件将失败.

...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?

推荐答案

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

The problem might be with your mail server. Many servers don't like sending corrupted PDFs, which would be any PDF that doesn't look like a normal PDF - say, a string of English text.

在我了解如何用PHP生成PDF之前,您还可以发送其他任何类型的附件吗?

Are you able to send any other kind of attachment, before I get into how to generate a PDF in PHP?

这篇关于使用PHP或PHPMailer通过电子邮件填充PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆