[英]PHP contact form with Freehostia
I cannot get this form to send if I use anything other than $from = 'From: . $email';
如果我使用$from = 'From: . $email';
以外的其他格式,则无法发送此表单$from = 'From: . $email';
$from = 'From: . $email';
. 。 If I change it to anything else, it will not send. 如果我将其更改为其他任何内容,它将不会发送。 When it does send with this information, it comes in from .$email@mbox.freehostia.com
. 当它确实发送此信息时,它来自.$email@mbox.freehostia.com
。
What I would prefer is have the from email address be the email that was submitted in the form, so the receiver can respond without having to create a new email. 我希望发件人的电子邮件地址是表单中提交的电子邮件,因此收件人可以响应而无需创建新电子邮件。 I've searched everything and can't find an answer to this specific issue. 我已经搜索了所有内容,但找不到此特定问题的答案。
<?php
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$from = 'From: . $email';
$to = 'info@resourcedmichigan.com';
$subject = 'ResourcED Career Submission';
$body = "From: $name\nEmail: $email\nPhone Number: $phone\nMessage: $message";
if ($_POST['submit']) {
if (mail ($to, $subject, $body, $from)) {
include("inc/header.php");
echo '<div class="container"><div class="spacer-top"><h3>Thank you for your interest in ResourcED! We will be in contact with you soon!</h3></div></div>';
include("inc/footer.php");
} else {
echo '<div class="container"><h3>Something went wrong. Go back and try again!</h3></div>';
}
}
?>
Variables will not be interpolated inside of single quotes and the concatenation operator is unnecessary. 不会在单引号内插入变量,并且不需要串联运算符。
$from = 'From: . $email';
should be 应该
$from = "From: $email";
or 要么
$from = 'From: ' . $email;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.