sandbudd Posted June 25, 2010 Share Posted June 25, 2010 this is working fine on a linux server but not on a Unix? What I want is to display the name in the from of the email... on the unix it does not send the email. <?php $headers = "From: $name <>"; $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 = ""; $subject = "test"; $result = mail($to, $subject, $msg, $headers, "-f{$name}"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/ Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 if I take this out "-f{$name}" it sends the email but puts nothing in the from of the email Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077301 Share on other sites More sharing options...
Pikachu2000 Posted June 25, 2010 Share Posted June 25, 2010 The fifth parameter is optional, and will choke some servers that don't need it. Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077309 Share on other sites More sharing options...
premiso Posted June 25, 2010 Share Posted June 25, 2010 $headers = "From: $name <emailshouldbe@here.com>"; Maybe if you have a valid email address in there it may work alright for ya. The fifth parameter is optional, and will choke some servers that don't need it. It is optional, but given that he is using $name, and $name probably is not a valid email address. That is probably why that makes the email never send. The -f should be followed by a valid email address, not a name etc. As an FYI to the OP Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077310 Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 when I put an email address it displays the email fine but in the form it is not asking for an email address that is why I want it to display the name int the from... whats weird is that it works great on one server? Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077312 Share on other sites More sharing options...
premiso Posted June 25, 2010 Share Posted June 25, 2010 Well the SMTP could be auto setup to append an email address to anything with an invalid from address. But if it is coming from a form, why not do a "fake" no-reply email address IE: $headers = "From: $name <no-reply@yourdomain.com>"; // .... $result = mail($to, $subject, $msg, $headers, "-fno-reply@yourdomain.com"); Given that they should not reply to the email. If you want them to, then put your real email in there or something. But putting in a place holder like that is common, and tends to work just fine. But I do not know what your needs are so yea. Just an idea. Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077317 Share on other sites More sharing options...
Pikachu2000 Posted June 25, 2010 Share Posted June 25, 2010 Try leaving out the -f parameter, and set the From: header to include a valid email address and see what happens. Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077318 Share on other sites More sharing options...
sandbudd Posted June 25, 2010 Author Share Posted June 25, 2010 got it to work guys...here is what worked and displays the name in the email from...thanks for the help <?php $headers = "From:<>" .$_POST['name']. "\n\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 = ""; $subject = ""; $result = mail($to, $subject, $msg, $headers ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/#findComment-1077320 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.