gpt4 book ai didi

具有自定义邮件正文的 PHP 电子邮件脚本

转载 作者:行者123 更新时间:2023-12-04 15:54:47 25 4
gpt4 key购买 nike

我正在为联系表单使用 PHP 电子邮件脚本。表单有六个字段:

  • 姓名
  • 电子邮件
  • 电话号码
  • 预订日期
  • 预约时间
  • 评论

robotest 也有一个隐藏的蜜 jar 域。 PHP脚本如下:

 <?php 

$robotest = $_POST['robotest']; //just testin' for robots

$recipient = "info@mydomain.com"; //recipient
$email = ($_POST['email']); //senders e-mail adress

if((filter_var($email, FILTER_VALIDATE_EMAIL)) && ($robotest == "")) {

$Name = ($_POST['name']); //senders name

$mail_body = !!!----> WHAT DO I PUT HERE <----!!!!

$subject = "Porter Inquiry"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)

} else {
print "You've entered an invalid email address!";
}
?>

你会注意到上面,我把 !!!----> WHAT DO I PUT HERE <----!!! 放在哪里,我不确定如何将多个字段放入邮件正文中。我想包括以下内容:

"Hello,

You have received a new booking with the following details:

Booking Time: ($_POST['time']) Booking Date: ($_POST['date'])



Additional customer comments: ($_POST['comments']);

Please respond to the customer within 30 minutes on the following
phone number: ($_POST['phone'])

Warm regards,

Robot."

我找不到任何关于如何成功实现这一目标的信息,非常感谢一些指导。

最佳答案

我稍微修改了 Zoltan 的代码。现在应该可以工作了。

<?php 

$robotest = $_POST['robotest']; //just testin' for robots

$recipient = "info@mydomain.com"; //recipient
$email = ($_POST['email']); //senders e-mail adress

if((filter_var($email, FILTER_VALIDATE_EMAIL)) && ($robotest == "")) {

$Name = ($_POST['name']); //senders name

$mail_body = "Hello, \r\n";
$mail_body .= "You have received a new booking with the following details: \r\n";
$mail_body .= "Booking Time: ({$_POST['time']}) Booking Date: ({$_POST['date']}) \r\n";
$mail_body .= "Additional customer comments: ({$_POST['comments']}); \r\n";
$mail_body .= "Please respond to the customer within 30 minutes on the following phone number: ({$_POST['phone']}) \r\n";
$mail_body .= "Warm regards, \r\n";
$mail_body .= "Robot. \r\n";



$subject = "Porter Inquiry"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

mail($recipient, $subject, $mail_body, $header); //mail command :)

} else {
print "You've entered an invalid email address!";
}
?>

希望这会有所帮助...是的,即使字段为空(收件人字段除外),这也会发送邮件

喧嚣

关于具有自定义邮件正文的 PHP 电子邮件脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13318759/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com