【发布时间】:2017-07-06 09:25:51
【问题描述】:
这是 php 代码及其工作,所有表单内容成功发送到邮件 ID,但我想使用 php 这个函数将 PDF 文件也附加到电子邮件。 但我怎么能,我不知道。
我想将指定的 PDF 文件作为文件附件添加到电子邮件中。我该怎么做?
<?php
$name = $_REQUEST["name"];
$phone = $_REQUEST["phone"];
$email = $_REQUEST["email"];
$address = $_REQUEST["address"];
$message = $_REQUEST["message"];
date_default_timezone_set("Asia/Calcutta");
$todayis = date("y-m-d H:i:s", time());
$subject = "PVC Order From Website ";
$to = "iamrightful@gmail.com";
$msg .= "<table width='600' border='0' align='center' cellpadding='0' ellspacing='0' style='font-family:Arial, Helvetica, sans-serif;
font-size:13pt; border:1px solid #0f3f6a;'>";
$msg .= "<tr>";
$msg .= "<td width='16' height='25' bgcolor='#f9cf7b'> </td>";
$msg .= "<td width='96' bgcolor='#f9cf7b'>Name</td>";
$msg .= "<td width='10' height='25' bgcolor='#f9cf7b'><strong>:</strong></td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'>$name</td>";
$msg .= "</tr>";
$msg .= "<tr>";
$msg .= "<td height='25' bgcolor='#f9cf7b'> </td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'>Mobile </td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'><strong>:</strong></td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'>$phone</td>";
$msg .= "</tr>";
$msg .= "<tr>";
$msg .= "<tr>";
$msg .= "<td height='25' bgcolor='#f9cf7b'> </td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'>Email Id </td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'><strong>:</strong></td>";
$msg .= "<td height='25' bgcolor='#f9cf7b'>$email</td>";
$msg .= "</tr>";
$msg .= "<tr>";
$msg .= "<td height='25'> </td>";
$msg .= "<td height='25'>Address</td>";
$msg .= "<td height='25'><strong>:</strong></td>";
$msg .= "<td height='25'>$address</td>";
$msg .= "</tr>";
$msg .= "<tr>";
$msg .= "<td height='25'> </td>";
$msg .= "<td height='25'>Discription</td>";
$msg .= "<td height='25'><strong>:</strong></td>";
$msg .= "<td height='25'>$message</td>";
$msg .= "</tr>";
$msg .= "</table>";
$headers = "From: $c_name < $c_email >.";
$headers = "Bcc: admin < $Bcc >.";
$headers .= "\r\nContent-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $msg, $headers);
header("Location:thankyou.html");
【问题讨论】:
-
帮自己一个忙,使用现有的库,如 PHPMailer。将消除这样做的所有痛苦。
标签: php forms pdf email-attachments