我希望有人可以帮我解决我面临的这个问题。
我有一个简单的PHP表单,显示错误我不知道为什么,这是代码:
<?php
// Get values from form
$name=$_POST['name'];
$email=$_POST['email'];
$emailconfirmation=$_POST['emailconfirmation'];
$phone=$_POST['phone'];
$address=$_POST['address'];
$postcode=$_POST['postcode'];
$eventarea=$_POST['eventarea'];
$typeevent=$_POST['typeevent'];
$eventdate=$_POST['eventdate'];
$guestnumber=$_POST['guestnumber'];
$extraguests=$_POST['extraguests'];
$siteformarquee=$_POST['siteformarquee'];
$seatedorstanding=$_POST['seatedorstanding'];
$dancefloor=$_POST['dancefloor'];
$servicetent=$_POST['servicetent'];
$surfacemarquee=$_POST['surfacemarquee'];
$details=$_POST['details'];
$town=$_POST['town'];
$to = "email@email.com, email2@email.com";
$subject = "Quote to review from Elite Marquees";
$message = " Name: " . $name . "\r\n Town of the Event: " . $town . "\r\n Telephone Number: " . $phone . "\r\n Email: " . $email . "\r\n Confirm Email Address: " . $emailconfirmation . "\r\n Address: " . $address . "\r\n Post Code: " . $postcode . "\r\n The area where your event will take place: " . $eventarea . "\r\n Type of the Event: " . $typeevent . "\r\n Date of the Event: " . $eventdate . "\r\n Number of Guests: " . $guestnumber . "\r\n If a wedding how many extra guests for the evening?: " . $extraguests . "\r\n Town Where the Event will take place: " . $town . "\r\n Do you have a venue or site for the marquee?: " . $siteformarquee . "\r\n Will your guests be seated or standing?: " . $seatedorstanding . "\r\n Do you require a dance floor?: " . $dancefloor . "\r\n Do you require a service tent?: " . $servicetent . "\r\n Type of surface the marquee will be erected on?: " . $surfacemarquee . "\r\n Details or Questions?: " . $details;
/*$from = "Elite Marquees";*/
$headers = "From: Elite Marquees <info@elitemarquees.com>" . "\r\n";
$headers .= "Content-type: text/plain; charset=UTF-8" . "\r\n";
if(@mail($to,$subject,$message,$headers))
{
print "<script>document.location.href='http://elite-marquees.co.uk/success.html';</script>";
}else{
echo "Error! Please try again.";
}
?>
有人可以帮帮我吗?
谢谢!
答案 0 :(得分:0)
如果成功接受邮件传递,则返回TRUE, 否则就错了。
重要的是要注意,因为邮件被接受了 交付,并不意味着邮件实际上会达到预期的目的 目的地。
基本上,邮件功能失败。
首先,检查您是否可以在服务器上发送测试邮件。如果您无法将服务器设置配置为使用电子邮件。
尝试并调用一个非常简单,硬编码的mail()
。
如果仍然失败,那么您的服务器设置为99%。检查您的php.ini
设置,并确保您的服务器可以支持发送电子邮件。
答案 1 :(得分:0)
你得到了哪个错误? 你的php.ini是否更新了以下几行?
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
sendmail_from = Your Email ID
; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path =/usr/sbin/sendmail
答案 2 :(得分:0)
您作为FROM使用的电子邮件必须与网站位于同一服务器上,这意味着info@elite-marquees.co.uk可以正常运行但不是info@elitemarquees.com
尝试在mail()命令中添加第五个参数:
mail($to,$subject,$message,$headers,"-f info@elitemarquees.com");
答案 3 :(得分:0)
首先在邮件功能之前删除@。再次尝试如果再次出现错误,你必须检查你可以用于var_dump(邮件(你的邮件))或死亡的值是什么?函数来检查值,如果它给出null意味着缺少某些东西。然后再次检查var_dump是否有其他值,您很快就会发现错误 可能对你有帮助。
答案 4 :(得分:0)
问题来自<info@elitemarquees.com>
我将其更改为<info@elitemarquees.co.uk>
,现在它正在运作。
感谢你们所有人!你摇滚!