Krishna Pariyar
Krishna Pariyar

Reputation: 111

php mail function from email address shows mail server address

Following are my code to send reservation from a form. Everything is sent as per the form but the in my inbox FROM section it shows mail server address instead of showing senders email address.

<?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='[email protected]'; 
      // 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>"; 
      } 
  }
?>

Upvotes: 0

Views: 801

Answers (2)

exceptional exception
exceptional exception

Reputation: 527

I believe the from: portion has to be RFC 2822-compliant (an email address format). See Here: http://php.net/manual/en/function.mail.php

Upvotes: 0

N.DeNisse
N.DeNisse

Reputation: 149

This is normal. It really depends on the web server where you are hosting and the email service you are using. Research your hosting where you use the mail function. Most likely this happens because you pretend to send the message from person who fills up the form on your website and the mail server detects it as fraudulent... my guess... when I had the same problem and did some poking around.

Hope this was helpful.

Upvotes: 1

Related Questions