Help - Search - Members - Calendar
Full Version: php mail
Hostony Board > General Support > PHP/MySQL
Tim
When I send mail using php mail, the recipient always sees "<nobody@server26.fastbighost.com>" as the "

Return-path". I would like them to see my actual e-mail instead. Can someone help?

I'm using the following code (fictitous site name used here):
mail("xx974@yahoo.com", "TESTING.", "this is a test", "From: me@myWeb.com\r\nReply-To: me@myWeb.com");

I've even tried:
ini_set("sendmail_from", "me@myWeb.com");
and still get the same results even though "phpinfo()" then seems to show the change. The recipient is

shown the following which looks just a little weird:



Return-path: <nobody@server26.fastbighost.com>
Envelope-to: xx974@yahoo.com
Delivery-date: Wed, 10 Aug 2005 14:29:57 +0000
Received: from nobody by server26.fastbighost.com with local (Exim 4.51)
id 1E2rae-0004fB-O9
for xx974@yahoo.com; Wed, 10 Aug 2005 14:29:56 +0000
To: xx974@yahoo.com
Subject: TESTING.
From: me@myWeb.com
Reply-To: me@myWeb.com
Message-Id: <E1E2rae-0004fB-O9@server26.fastbighost.com>
Sender: Nobody <nobody@server26.fastbighost.com>
Date: Wed, 10 Aug 2005 14:29:56 +0000
Niels
Try this:

CODE
  $headers  = "MIME-Version: 1.0\n";
  $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
  $headers .= "X-Priority: 3\n";
  $headers .= "X-MSMail-Priority: Normal\n";
  $headers .= "X-Mailer: PHP\n";
  $headers .= "From: \"".$name_sender."\" <".$sender.">\n";
  $headers .="Return-Path: your@email.com\n";
  return mail($email, $subject, $message, $headers);


That's alot more then what you asked for, this is the exact part you want:

CODE
  $headers .="Return-Path: your@email.com\n";


But i would advice you to use the full headers as shown above (to keep the spam filters happy tongue.gif ), just modify a bit and it should work.

-
niels
Tim
QUOTE(Niels @ Aug 11 2005, 10:46 AM)
Try this:

CODE
  $headers  = "MIME-Version: 1.0\n";
  $headers .= "Content-type: text/plain; charset=iso-8859-1\n";
  $headers .= "X-Priority: 3\n";
  $headers .= "X-MSMail-Priority: Normal\n";
  $headers .= "X-Mailer: PHP\n";
  $headers .= "From: \"".$name_sender."\" <".$sender.">\n";
  $headers .="Return-Path: your@email.com\n";
  return mail($email, $subject, $message, $headers);


That's alot more then what you asked for, this is the exact part you want:

CODE
  $headers .="Return-Path: your@email.com\n";


But i would advice you to use the full headers as shown above (to keep the spam filters happy  tongue.gif ), just modify a bit and it should work.

-
niels
*


Thanks, but that didn't work either.
Here is the actual code that I used with the actual e-mails so you can see the actual results:
<?php
$name_sender="Tim";
$sender="tim";
$email="timv@flutespirit.com";
$subject="TESTING";
$message="This is a test";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP\n";
$headers .= "From: \"".$name_sender."\" <".$sender.">\n";
$headers .="Return-Path: timv@violinbridgeworks.com\n";
mail($email, $subject, $message, $headers);
exit();
?>


Here is what the e-mail software received:
Return-path: <nobody@server26.fastbighost.com>
Envelope-to: timv@flutespirit.com
Delivery-date: Fri, 12 Aug 2005 01:19:32 +0000
Received: from nobody by server26.fastbighost.com with local (Exim 4.51)
id 1E3OCq-0001LM-4u
for timv@flutespirit.com; Fri, 12 Aug 2005 01:19:32 +0000
To: timv@flutespirit.com
Subject: TESTING
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: PHP
From: "Tim" <tim@server26.fastbighost.com>
Message-Id: <E1E3OCq-0001LM-4u@server26.fastbighost.com>
Sender: Nobody <nobody@server26.fastbighost.com>
Date: Fri, 12 Aug 2005 01:19:32 +0000


If I click on the reply button in my e-mail software, the name that ends up going into the reply box is:
"timv@violinbridgeworks.com" <tim@server26.fastbighost.com>


If I go about it the othe way (with actual entries):
<?php
$theMsg="This is a test";
mail("timv@flutespirit.com", "testing", $theMsg, "From: timv@violinbridgeworks.com\r\nReply-To: timv@violinbridgeworks.com");
?>


The email received by my e-mail software looks like this:
Return-path: <nobody@server26.fastbighost.com>
Envelope-to: timv@flutespirit.com
Delivery-date: Fri, 12 Aug 2005 01:46:03 +0000
Received: from nobody by server26.fastbighost.com with local (Exim 4.51)
id 1E3OcV-0005SX-Ht
for timv@flutespirit.com; Fri, 12 Aug 2005 01:46:03 +0000
To: timv@flutespirit.com
Subject: testing
From: timv@violinbridgeworks.com
Reply-To: timv@violinbridgeworks.com
Message-Id: <E1E3OcV-0005SX-Ht@server26.fastbighost.com>
Sender: Nobody <nobody@server26.fastbighost.com>
Date: Fri, 12 Aug 2005 01:46:03 +0000

This is a test


If I click on the reply button in my e-mail software, the name that ends up going into the reply box is:
timv@violinbridgeworks.com

Which is the way it should be, but it still has that funky "Received:" entry


Any other ideas how to get around this so that "Return-path:" ends up with the correct entry? sad.gif
Niels
Try this:

CODE
<?php
$name_sender="Tim";
$sender="timv@flutespirit.com"; //sending from this address
$email="timv@flutespirit.com"; //sending to this address
$subject="TESTING";
$message="This is a test";

$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP\n";
$headers .= "From: \"".$name_sender."\" <".$sender.">\n";
$headers .="Return-Path: timv@violinbridgeworks.com\n";
mail($email, $subject, $message, $headers);
exit();
?>


$sender must be an email address, see the notes.

I just tested this and it worked:
QUOTE
Received: by 10.36.221.15 with SMTP id t15mr451323nzg;
        Sat, 13 Aug 2005 08:41:43 -0700 (PDT)
Return-Path: <timv@flutespirit.com>


Good luck

-
Niels
Tim
I wonder why it doesn't work for me? Perhaps the mail server you are using and the one I'm using are configured a little differently?

Once again, here is the modified code as per your instruction:
<?php
$name_sender="tim";
$sender="tim@violinbridgeworks.com";
$email="timv@flutespirit.com";
$subject="TESTING";
$message="This is just a test";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: PHP\n";
$headers .= "From: \"".$name_sender."\" <".$sender.">\n";
$headers .="Return-Path: timv@violinbridgeworks.com\n";
mail($email, $subject, $message, $headers);
?>



When I open the mail using an old eudora 1.5.2, I get:
Return-path: <nobody@server26.fastbighost.com>
Envelope-to: timv@flutespirit.com
Delivery-date: Sat, 13 Aug 2005 18:33:27 +0000
Received: from nobody by server26.fastbighost.com with local (Exim 4.51)
id 1E40ox-0005LX-4s
for timv@flutespirit.com; Sat, 13 Aug 2005 18:33:27 +0000
To: timv@flutespirit.com
Subject: TESTING
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: PHP
From: "tim" <tim@violinbridgeworks.com>
Message-Id: <E1E40ox-0005LX-4s@server26.fastbighost.com>
Sender: Nobody <nobody@server26.fastbighost.com>
Date: Sat, 13 Aug 2005 18:33:27 +0000


This is just a test


Any ideas? I should probably add that I do have another domain hosted with yahoo hosting and they do something special in regard to enabling php e-mail sending and whatever they do, all of this sort of thing does work just fine with all the entries being filled in okay, which makes me wonder if it's server related whereas the one you are on is set up ok and the one I'm using is set up defferently.
Tim
Maybe someone at hostony saw this and is working to fix. My mail and cpanel was down and now it's up. Then the php server went down and back up a couple of times (no php pages load just html), so hopefully that's what's going on. smile.gif
Niels
I hope you get it working, if i got time i can look @ it on monday.
Good luck!

-
Niels
Tim
Thanks. I'll let you know if and how it gets fixed.
Tim
For those of you who may have been following along - I finally figured out the problem. Apparently, there is a bug reported in the php system that causes the "Reply-path" in the received email to be set to whatever is interpreted from the "sendmail_from =" entry in the php.ini file regardless of what is passed via script in the way of header definition. Even the use of "ini_set('sendmail_from', $mailFrom);" doesn't do anything. Here's a link that goes to a discussion about the bug:
http://bugs.php.net/bug.php?id=28976

I'm on a server with the php compiled as an apache module, so there isn't really a workaround until there is a version that has the fix. I've been advised that it can be worked around if on a server with the php running as cgi. I'm not sure if that has to do with hardcoding the address into the .ini file, or if it has to do with just fixing the php script that isn't working quite right as is discussed at the link given above.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.
IPS Driver Error

IPS Driver Error

There appears to be an error with the database.
You can try to refresh the page by clicking here