Jump to content

Works on one server but not another


sandbudd

Recommended Posts

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}");
?>

Link to comment
https://forums.phpfreaks.com/topic/205876-works-on-one-server-but-not-another/
Share on other sites

$headers = "From: $name <[email protected]>";

 

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

 

 

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 <[email protected]>";
// ....
$result = mail($to, $subject, $msg, $headers, "[email protected]");

 

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.

 

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 );
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.