Forum Moderators: coopster

Message Too Old, No Replies

Pesky mail() problem

headers break the script

         

lorax

1:12 am on Oct 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



My PHP script works great when I include the values for to, subject, msg, from and bcc but when I try to add additional headers like reply-to the script simply does not send the email. No errors reported.

jatar_k

1:53 am on Oct 18, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I have gone to a standard set of headers and it has fixed all of my mail probs across various servers.

$from .= "From: $someemail\n";
$from .= "X-Sender: $someemail\n";
$from .= "X-Mailer: PHP\n";
$from .= "X-Priority: 3\n";
$from .= "Return-Path: $someemail\n";
$from .= "Reply-To: $siteemail\n";
mail($to,$subject,$message,$from);

I also have gotten into the habit of putting hard returns in messages for another problem I found. So far it has done very well across many, many servers.

I hate email

lorax

3:59 am on Oct 18, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> I hate email

ROFLMAO - that made my night ;)

Thanks for the snippet. I'll give it a try in the morning.

lorax

6:41 pm on Oct 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well I made the change and am receiving the email but the From is "Root User" <root@domain.com> even though I've specified the "From" var.

dmorison

6:45 pm on Oct 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just curious...

$from .= "X-Mailer: PHP\n";

... is there a good reason for including this?

jatar_k

10:37 pm on Oct 19, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I thought it was a strange one too but it seems to help with some of the many servers I have the misfortune of working with.

That single header helped a few out, I have no clue why it would matter but it seems to.

have you looked at the mail headers when you receive it to see if there is any extra info in there? What type of server is it?

lorax

3:30 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thank jatar_k - that worked like a charm. It does seem to need the X-Mailer line - not sure why that makes a difference.

>> have you looked at the mail headers when you receive it to see if there is any extra info in there? What type of server is it?

This is the raw view:

X-From_: root@website.com Tue Oct 21 01:47:11 2003
Return-Path: <root@website.com>
Received: from website.com (website.com [xx.xx.xx.xxx])
by mybiz.mailserver.com (8.12.10/8.12.9) with ESMTP id h9L5lAC4046014
for <myemail@mydomain.com>; Tue, 21 Oct 2003 01:47:11 -0400 (EDT)
Received: (from root@localhost)
by website.com (8.11.6/8.11.6) id h9L5lAV05608;
Mon, 20 Oct 2003 23:47:10 -0600
Date: Mon, 20 Oct 2003 23:47:10 -0600
From: Root User <root@website.com>
Message-Id: <200310210547.h9L5lAV05608@website.com>
To: client@website.com
Subject: Need Info Request
Message
From: sales@website.com
X-Sender: sales@website.com
X-Mailer: PHP
X-Priority: 3
Reply-To: sales@website.com

It's a linux box with an Apache server using SendMail. It's not a big deal at this moment who it comes from since the email does get sent and is received by the client. Though I would like to understand why it chooses Root User and what I could do to change if I wanted to.

jatar_k

3:40 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



hmm, I have never really looked too deeply at it because I am really nice to sysadmins and they do all the messing with apache and sendmail.

is php running as root? usually everything is set as nobody and you get really strange return paths but I have had them throw root in there once in a while.

shared hosts cause all kinds of messes when it comes to email, I have found that header list to be the most reliable, also make sure you put hard returns in the message. If you are on your own server you can mess around a lot more. Take a look at sendmail settings or even apache. On a windows server it uses the sendmail_from in php.ini, I have noticed that address, if set, often matches the default even on *nix.

I hate email more all the time

lorax

3:45 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



It is a shared host. I don't know if PHP is running as root but I would suspect it uses the user which owns the webspace (this is a westhost setup). I'll look into more at another time - which means I'll ignore it until it breaks or I'm really bored. ;)

jatar_k

3:46 pm on Oct 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



always the best call with email, hehe