教育我:)
我有一个简单的 HTML 表单,由 3 个字段组成:姓名、电子邮件和消息。
我在下面创建了一些 PHP 代码,它将充当输入到包含固定消息和附件的表单中的电子邮件地址的自动回复器。
我希望将第二封电子邮件发送到一个固定的电子邮件地址给一家公司,该地址仅包含输入表格的姓名、电子邮件和消息。
<?php
$field_fullname = $_POST['cf_mercury']; // cf_name is a convention used by the HTML form
$field_email = $_POST['cf_jupiter'];
$field_message = $_POST['cf_uranus'];
require_once('class.phpmailer.php');
$mail = new PHPMailer(); // defaults to using php "mail()"
$body = $field_message;
$mail->SetFrom("company@address.co.uk", "ETAP Centre");
$mail->AddReplyTo("company@address.co.uk", "ETAP Centre");
$address = "email@address.co.uk";
$mail->AddAddress($field_email, $field_fullname);
$mail->Subject = 'Auto Response: Message from the ETAP Centre';
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$mail->AddAttachment(""); // attachment
$mail->AddAttachment(""); // attachment
if(!$mail->Send()) {
{ ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send your email to company@address.co.uk');
window.location = 'index.html';
</script>
<?php
}
} else {
?>
<script language="javascript" type="text/javascript">
alert('Thank you for contacting the ETAP Centre. We will contact you shortly.');
window.location = 'index.html';
</script>
<?php
}
?>
任何和所有的帮助都将不胜感激,如果我能做更多的事情来表达我的问题并增加它的可理解性,请告诉我。谢谢!