nandos Posted June 1, 2011 Share Posted June 1, 2011 Hi, Does anybody know why I'm seeing "nobody" on the email "from" header why I receive email which is sent by the web form? Below is the code, I deeply appreciate if someone can tell me what I did wrong [color=red]<?PHP /* SUBJECT AND EMAIL VARIABLE */ $emailSubject = ' Crystal Ashley Web Enquiry Form '; $webMaster = '[email protected], [email protected] '; /* gathering data variable */ $emailField = $_POST['email'] ; $nameField = $_POST['name'] ; $phoneField = $_POST['phone'] ; $countryField = $_POST['country'] ; $commentsField = $_POST['comments'] ; $body = <<<EOD <br><hr><br> Email : $email <br> Name : $name <br> Comments : $comments <br> <br> EOD; $headers = "From : $emailSubject\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /*results rendered as html*/ $theResults = <<<EOD <html> <head> <title>Crystalashley</title> </head> <div> <div align="left"><img src="../images/logo.png" width="454" height="407"></div> </div> </body> </html> EOD; echo "$theResults"; ?>[/color] Quote Link to comment https://forums.phpfreaks.com/topic/238145-from-header-shows-nobody/ Share on other sites More sharing options...
Pikachu2000 Posted June 1, 2011 Share Posted June 1, 2011 The From: header should be an email address that is valid on your server, not the email the user submits. And the value assignment to the variable in your code is assigning the Subject string to the From: header . . . $headers = "From : $emailSubject\r\n"; Quote Link to comment https://forums.phpfreaks.com/topic/238145-from-header-shows-nobody/#findComment-1223743 Share on other sites More sharing options...
kenrbnsn Posted June 2, 2011 Share Posted June 2, 2011 Try this code and see which message makes it through and what the From line reads: <?php $from = array('[email protected]','[email protected]'); foreach ($from as $f) { mail('[email protected]','Test from 2','Again, nothing here',"From: Just Testing <$f>","-f $f"); } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/238145-from-header-shows-nobody/#findComment-1223881 Share on other sites More sharing options...
nandos Posted June 2, 2011 Author Share Posted June 2, 2011 I've changed the code but it's still not working <?PHP /* SUBJECT AND EMAIL VARIABLE */ $emailSubject = ' Crystal Ashley Web Enquiry Form '; $webMaster = '[email protected], [email protected] '; /* gathering data variable */ $emailField = $_POST['email'] ; $nameField = $_POST['name'] ; $phoneField = $_POST['phone'] ; $countryField = $_POST['country'] ; $commentsField = $_POST['comments'] ; $body = <<<EOD <br><hr><br> Email : $email <br> Name : $name <br> Phone : $phone <br> Country : $country <br> Message : $comments <br> <br> EOD; $headers = "From : $webMaster\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/238145-from-header-shows-nobody/#findComment-1224347 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.