以下是我从表单发送预订的代码。所有内容都按照表单发送,但在我的收件箱FROM部分显示邮件服务器地址而不是显示发件人电子邮件地址。
<?php
if(isset($_POST['rsubmit'])){
//echo "samir karmachary";
$fname=$_POST['fname'];
$remail=$_POST['remail'];
$rphone=$_POST['rphone'];
$pick_up_date=$_POST['pick_up_date'];
$pick_up_time=$_POST['pick_hour'].":".$_POST['pick_min']."".$_POST['pick_ampm'];
$taxitype=$_POST['taxitype'];
$ploc=$_POST['ploc'];
$dloc=$_POST['dloc'];
$passangerno=$_POST['passangerno'];
$luggageno=$_POST['luggageno'];
$comment=$_POST['comment'];
$payment_type=$_POST['payment_type'];
$to='example@address.com';
// subject
$subject = 'Reservation detail convenience';
// message
$message = ' <html> <head> <title>Reservation Detail Convenience</title> </head> <body> <table width=100% cellpadding="4" cellspacing="4"> <tr><td width="30%" >Name :</td><td>'.$fname.'</td></tr> <tr><td>Email :</td><td>'.$remail.'</td></tr> <tr> <td>Phone :</td><td>'.$rphone.'</td></tr> <tr><td>Pick up Date:</td><td>'.$pick_up_date.'</td></tr> <tr><td>Pick up Time:</td><td>'.$pick_up_time.'</td></tr> <tr><td>Taxi Type:</td><td>'.$taxitype.'</td></tr> <tr><td>Pick Up location:</td><td>'.$ploc.'</td></tr> <tr><td>Drop Of Location:</td><td>'.$dloc.'</td></tr> <tr><td>Passanger No:</td><td>'.$passangerno.'</td></tr> <tr><td>Luggage No:</td><td>'.$luggageno.'</td></tr> <tr><td>Comment:</td><td>'.$comment.'</td></tr> <tr><td>Payment:</td><td>'.$payment_type.'</td></tr> </table> </body> </html> ';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: Convernience<Convernience>' . "\r\n";
if(mail($to, $subject, $message, $headers)){
$to=$remail; mail($to, $subject, $message, $headers);
echo "<script type='text/javascript'>alert('Reservation successfully');</script>";
}else{
echo "<script type='text/javascript'>alert('Sorry please try again');</script>";
}
}
?>
答案 0 :(得分:1)
这很正常。这实际上取决于您托管的Web服务器以及您正在使用的电子邮件服务。研究您使用邮件功能的主机。最有可能发生这种情况是因为你假装从填写表格的人那里发送邮件而邮件服务器检测到它是欺诈性的......我的猜测...当我遇到同样的问题并做了一些探讨时。 / p>
希望这有用。
答案 1 :(得分:0)
我认为from:部分必须符合RFC 2822(电子邮件地址格式)。看这里: http://php.net/manual/en/function.mail.php