sandbudd Posted June 25, 2010 Share Posted June 25, 2010 I am wanting the name to appear in the from in the email.... This is what I am getting [email protected] which I know is my server... Im not sure what I need to do? <?php $headers = 'From: '.$name."\r\n"; $msg = "From:\n" .$_POST['name']."\n\n"; $msg .= "Address:\n".$_POST['address']."\n\n"; $msg .= "Suite:\n".$_POST['suite']."\n\n"; $msg .= "City:\n".$_POST['city']."\n\n"; $msg .= "State:\n".$_POST['state']."\n\n"; $msg .= "Zip Code:\n".$_POST['zip']."\n\n"; $to = "[email protected]"; $subject = "Website Request"; $result = mail($to, $subject, $msg, $headers); ?> Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/ Share on other sites More sharing options...
mrMarcus Posted June 25, 2010 Share Posted June 25, 2010 Try the optional 5th mail parameter: $result = mail($to, $subject, $msg, $headers, "-f{$name}"); Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077218 Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 now I get the name with [email protected] Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077221 Share on other sites More sharing options...
kenrbnsn Posted June 25, 2010 Share Posted June 25, 2010 Where are you setting the variable "$name"? If you want a name to appear in the from line, that line needs to formatted like: <?php $headers = "From: Some Name <[email protected]>"; ?> Ken Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077224 Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 Name is being set in the form and there is no email address field Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077234 Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 This would actually work if I could hide <[email protected]> Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077236 Share on other sites More sharing options...
Jax2 Posted June 25, 2010 Share Posted June 25, 2010 I always thought for emails to work correctly, they need a from email address .... I.e. [email protected], not just a name, and that is probably why your server is inputting it's own email address... I could be wrong, but I think you may need to set it up so that it comes from any email, like [email protected] -- also helps anyhow to take care of spam problems, that is, so you're not seen as a spammer .... Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077237 Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 got it working...thanks Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077238 Share on other sites More sharing options...
Jax2 Posted June 25, 2010 Share Posted June 25, 2010 If you happen to check this thread again, can you say what the problem was? Just in case someone else with a like problem reads it over ... Thanks much! Glad you got it working. Link to comment https://forums.phpfreaks.com/topic/205860-simple-email-form/#findComment-1077239 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.