Jump to content

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 <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

 

 

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.

 

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.