大家好,我有一个非常基本的 php 问题,关于将表单数据添加到使用 phpmailer 发送的 html/php 文件中
我使用 gmail 帐户 SMTP 在成功提交表单后发送 HTML 电子邮件。
提交表单时,HTML 电子邮件已成功发送。
问题/问题:
我无法附加输入到我作为电子邮件发送的 HTML 文件中的各种标题中的表单数据。
这是调用的 PHP 代码:用于表单提交。email-content.php 是使用 Gmail SMTP 作为 HTML 电子邮件成功发送的文件。
<?php
$salutation = $_POST['salutation'] ;
$name = $_POST['name'] ;
//
$dateDOB = $_POST['DOB_Day'] ;
$monthDOB = $_POST['DOB_Month'] ;
$yearDOB = $_POST['DOB_Year'] ;
//
$mobileLandline1 = $_POST['mobileLandline1'] ;
$mobileLandline2 = $_POST['mobileLandline2'] ;
$mobileLandline3 = $_POST['mobileLandline3'] ;
$mobileLandline4 = $_POST['mobileLandline4'] ;
$mobileLandline5 = $_POST['mobileLandline5'] ;
$mobileLandline6 = $_POST['mobileLandline6'] ;
$mobileLandline7 = $_POST['mobileLandline7'] ;
$mobileLandline8 = $_POST['mobileLandline8'] ;
//
$language = $_POST['language'] ;
//
$address = $_POST['address'] ;
$city = $_POST['city'] ;
$state = $_POST['state'] ;
$pin = $_POST['pin'] ;
//
$fax = $_POST['fax'] ;
$email = $_POST['email'] ;
//
$passwordOption = $_POST['passwordOption'] ;
$passwordOptionProvided = $_POST['passwordOptionProvided'] ;
//Using PHPMailer with GMAIL
include("class.phpmailer.php");
include("class.smtp.php"); // note, this is optional - gets called from main class if not already loaded
$mail = new PHPMailer();
$body = $mail->getFile('email-content.php');
$body = eregi_replace("[\]",'',$body);
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "####@gmail.com"; // GMAIL username
$mail->Password = "#######"; // GMAIL password
$mail->From = "subscriptionForm@abc.com";
$mail->FromName = "Subscrition Form";
$mail->Subject = "SUBSCRIPTION FORM DETAILS FROM WEBSITE";
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->MsgHTML($body);
$mail->AddReplyTo("replyto@yourdomain.com","Webmaster, ####.com");
$mail->AddEmbeddedImage('logo.png', 'logo');
//$mail->AddAttachment("/path/to/file.zip"); // attachment
//$mail->AddAttachment("/path/to/image.jpg", "new.jpg"); // attachment
$mail->AddAddress("contact@abcd.com","Subscription Form");
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
header('Location: http://www.#####.com/subscription-form-fail.html');
} else {
//echo "Message has been sent";
// header('Location: $submissionsuccess');
header('Location: http://www.####.com/subscription-form-success.html');
}
?>
email-content.php 的代码:(部分 ho 我将 php 数据值调用到 HTML 模板中)
<table width="590" border="0" cellspacing="0" cellpadding="0" >
<tr>
<td align="left" valign="top" width="50" style="font-size:10pt; font-family:Tahoma, Geneva, sans-serif; padding:2px;">Name :</td>
<td align="left" valign="top" width="30" style="font-size:10pt; font-family:Tahoma, Geneva, sans-serif; padding:2px;"><?php $salutation ?></td>
<td align="left" valign="top" width="460" style="font-size:10pt; font-family:Tahoma, Geneva, sans-serif;">
<table width="460" border="1" cellspacing="0" cellpadding="0" style=" border-collapse:collapse;font-size:10pt; font-family:Tahoma, Geneva, sans-serif;border:1px solid #e0e3e5;" >
<tr>
<td style="padding:2px;"><?php $_POST['name'] ?></td>
</tr>
</table>
我是 php 编程的新手,我确定我在这里缺少一些非常基本的东西。提交的名称值在发送的 HTML 电子邮件中不可见。
对此问题的任何指导将不胜感激
谢谢
穆迪