Jaswinder Posted September 17, 2013 Share Posted September 17, 2013 hey friends.. the script is sending email .. but the problem is email is not showing the name and the email id of the sender,, rather it showing the hosting provider name.. as it was sending email to not the sender.. hope i can clear my problem ..here is the code. <form action="feed1.php" method="post"> <table width="100%"><tr><td>Name</td><td><input type="text" name="name" /></td></tr><tr><td>E-mail Id</td> <td><input type="text" name="email" /></td></tr><tr><td>Subject</td><td><input type="text" name="subject"/></td></tr><tr><td>Message</td><td><textarea rows="10" cols="20" name="message"></textarea></td></tr><tr><td colspan="2"><input type="submit" value="Send mail" name="sub" /></td></tr></table></form> feed1.php <?php error_reporting(-1);if (function_exists('mail')) {extract($_POST);if(!empty($name) && !empty($email) && !empty($subject) && !empty($message)){ if(filter_var($email, FILTER_VALIDATE_EMAIL)) {$to = "sehgal_jas@yahoo.com";$headers = 'MIME-Version: 1.0' . "\r\n";$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";$headers.= "From: ".$name."<".$email.">";// send messageif (mail($to, $subject, $message, $headers)){?><script type="text/javascript"> alert('Email Send') window.location='about.php'; </script><?php}else{?><script type="text/javascript"> alert('Sending Failed') window.location='about.php'; </script><?php} }else{?><script type="text/javascript"> alert('Enter valid Email id') window.location='about.php'; </script><?php }} else ?><script type="text/javascript"> alert('Enter all the fields') window.location='about.php'; </script><?php } else{?><script type="text/javascript"> alert('Mail function disabled.. Try again after sometime') window.location='about.php'; </script><?php}?> Problem The email is showing From: xyz@host261.hostmonster.com (not the email id of the sender and not its name).. any suggestions? you can check this form at http://www.poemquotejoke.com/about.php Quote Link to comment https://forums.phpfreaks.com/topic/282211-stuck-in-email-minor-problem/ Share on other sites More sharing options...
darkfreaks Posted September 17, 2013 Share Posted September 17, 2013 check your headers next time. $headers .= "From:".$name."<".$email.">\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/282211-stuck-in-email-minor-problem/#findComment-1449799 Share on other sites More sharing options...
mac_gyver Posted September 17, 2013 Share Posted September 17, 2013 the person filling out the form may be who is providing his email address in one of your form fields, but the email is NOT being sent from that email address. it is being sent from the mail server at your web hosting. you need to put the person's name/email into a Reply-to: header, not the From: header. the From: header should be an email address at your sending mail server, so that the receiving mail server will be less likely to mark the email as junk/spam. Quote Link to comment https://forums.phpfreaks.com/topic/282211-stuck-in-email-minor-problem/#findComment-1449801 Share on other sites More sharing options...
priyankagound Posted September 17, 2013 Share Posted September 17, 2013 fixed it by removing the 'greater than' and 'less than' characters around the email address. i.e <[your-email]> should be just [your-email] Quote Link to comment https://forums.phpfreaks.com/topic/282211-stuck-in-email-minor-problem/#findComment-1449816 Share on other sites More sharing options...
jazzman1 Posted September 17, 2013 Share Posted September 17, 2013 The proper formats are:From: user@domain.comORFrom: "user" <user@domain.com>User should be quoted, also there needs to be an empty space between "user" and <user@domain.com> check your headers next time. $headers .= "From:".$name."<".$email.">\r\n"; There is no problem to use html entities. $headers.= <<<EOD From: "$name" <$email> EOD; OR $headers.= <<<EOD From: "$name" <$email> EOD; fixed it by removing the 'greater than' and 'less than' characters around the email address No, it's not really necessary! you need to put the person's name/email into a Reply-to: header, not the From: header. the From: header should be an email address at your sending mail server, so that the receiving mail server will be less likely to mark the email as junk/spam Reply-to has nothing to do with the spam filter. In my opinion, the best way to verify that the email being delivered is to set a "FROM" addresses in the $header variable so that their system or the remote system knows whom to notify if delivery fails. There are lots of things that should be done to prevent emails going to a junk folder. @Jaswinder, why don't you consider using some php mail library. Quote Link to comment https://forums.phpfreaks.com/topic/282211-stuck-in-email-minor-problem/#findComment-1449864 Share on other sites More sharing options...
Jaswinder Posted September 18, 2013 Author Share Posted September 18, 2013 thanks for replies.... i look into it.. let see what result wil it gives out.. Quote Link to comment https://forums.phpfreaks.com/topic/282211-stuck-in-email-minor-problem/#findComment-1449972 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.