发送电子邮件填写PDF表格
Sending email filled PDF form
我想在点击提交按钮后通过电子邮件发送填好的表单,而不提示outlook或任何邮件。怎么能做到呢?
您的表单可以提交到您网站上的URL。该URL上的脚本可以捕获表单内容,并使用SMTP服务器将其发送出去。这与使用HTML表单没有什么不同,有些人喜欢PDF表单。PDF格式的表格可以下载、填写、打印,然后手工或邮寄。
我创建了PDF表单并添加了一个提交表单的按钮。在这个提交表单的操作中,我告诉它PDF完整的文档。
然后给它一个php页面的URL链接,比如mail_my_form.php
然后创建一个PHP表单,并将其命名为mail_my_form.php。
最后一件事是在php代码所在的根目录下创建一个名为pdfs
的文件夹。(如果你把php文件放在email文件夹中,那么在email文件夹中,你需要另一个名为pdf的文件夹)
现在这个脚本做的是:
- 保存PDF文件到文件名PDF。
- 然后将文件附加到电子邮件并发送。
- 然后从文件夹pdfs中删除文件以节省空间。(如果你想的话,你也可以使用删除功能将表单保存在FTP上。)
给你。
$fileatt = date("d-m-Y-His") . ".pdf"; // Creates unique PDF name from the date
copy('php://input',"pdfs/".$fileatt); // Copies the pdf form data to a folder named pdfs
$fileatt = "pdfs/".$fileatt; // Path to the file gives the pdfs folder plus the unique file name we just assigned
$fileatt_type = "application/pdf"; // File Type
$fileatt_name = "Application Form_".$fileatt.".pdf"; // Filename that will be used for the file as the attachment when it is sent
$email_from = "mywebsite"; // Who the email is from
$email_subject = "Completed online Applications"; // The Subject of the email
$email_message = "Please find a recent online application attached.
";
$email_message .= "Any problems please email me...
"; // Message that the email has in it
$email_to = "youremail@yourserver.com"; // Who the email is to
$headers = "From: ".$email_from;
//no need to change anything else under this point
$file = fopen($fileatt,'rb');
$data = fread($file,filesize($fileatt));
fclose($file);
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers .= "'nMIME-Version: 1.0'n" .
"Content-Type: multipart/mixed;'n" .
" boundary='"{$mime_boundary}'"";
$email_message .= "This is a multi-part message in MIME format.'n'n" .
"--{$mime_boundary}'n" .
"Content-Type:text/html; charset='"iso-8859-1'"'n" .
"Content-Transfer-Encoding: 7bit'n'n" .
$email_message .= "'n'n";
$data = chunk_split(base64_encode($data));
$email_message .= "--{$mime_boundary}'n" .
"Content-Type: {$fileatt_type};'n" .
" name='"{$fileatt_name}'"'n" .
//"Content-Disposition: attachment;'n" .
//" filename='"{$fileatt_name}'"'n" .
"Content-Transfer-Encoding: base64'n'n" .
$data .= "'n'n" .
"--{$mime_boundary}--'n";
$ok = @mail($email_to, $email_subject, $email_message, $headers);
if($ok) {
unlink($fileatt); //NOW WE DELETE THE FILE FROM THE FOLDER pdfs
Header("Location: nextpage.php"); //where do we go once the form has been submitted.
} else {
die("Sorry but the email could not be sent. Please go back and try again!");
}
相关文章:
- 如何使用javascript或html下载PDF格式的填写表单
- 我应该使用Ng提交还是点击表格
- HTML表格导出为具有适当列宽和字体的pdf
- 使用TableExport.js将HTML表格导出为PDF、WORD、PNG
- 在不使用200行var的情况下,在结果字段中添加顺序命名的变量?[PDF表格]
- 如何将表格html表格导出为PDF
- 是否可以使用 pdfmake.js 在 pdf 文件中重复表格行
- 如何使用pdfmake将html表格转换为pdf
- 如何通过jQuery/JavaScript将html表格导出到html页面中的excel或pdf
- pdf使表格标题在分页符上不重复
- 使用jsPDF生成PDF表格
- 在html中更改表格工具pdf标题名称
- 下载图表和表格的PDF格式
- 如何通过谷歌电子表格内的脚本发送PDF电子邮件
- 发送电子邮件填写PDF表格
- 如何导出多个html表格和多个d3生成的图形成一个单一的pdf
- 将html表格导出为pdf
- 如何使用Javascript在pdf上打印表格
- 使用jqgrid将html表格转换为pdf
- 在Javascript或Jquery中导出html表格和格式化的CSS到Excel或PDF文件