Re: mail() doesn't work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 9/14/2014 10:13 AM, Richard wrote:


------------ Original Message ------------
Date: Saturday, September 13, 2014 12:20:18 -0400
From: Jim Giner <jim.giner@xxxxxxxxxxxxxxxxxx>
To: php-general@xxxxxxxxxxxxx
Subject:  mail() doesn't work

ok - here's the scenario.  Wrote a script that has been copied
several times with success that traps an email, grabs some input
and then sends me an email.  Last week I attempted to make yet
another copy of it to capture a new email address and do the same
kind of thing.  Should have been easy, but it's a nightmare.

Let me say that my other instances of this template still work
just fine.  It's just this one that doesn't and I'm out of ideas.
The same email call is being used across the board. Here's the
code:

	$headers[] = "From: $incoming_email";
	$headers[] = "Reply-To: $reply_to";
	$headers[] = "X-Mailer: PHP/" . phpversion();
	$header_str = implode("\r\n", $headers);
	$ans_msg = wordwrap($ans_msg, 70, "\r\n");
	if (mail($to, $subject, $ans_msg, $header_str))
		PostErrorLog("Email sent to $to",$done);
	else
		PostErrorLog("Email failed");

The function posterrorlog makes a call to error_log to output some
messages since the email is not being sent.  The call to mail()
actually returns true yet it never delivers the message.  The $to
address is the same one I use in all of my versions of this
script.  The fact that my error log contains messages from the
script proves that the call actually gets executed, yet no mail.
The mailbox shows nothing on my host's webmail interface either.
It's like the mail goes to thin air. I have tried it with a simple
body of a dummy string value but that didn't help.  The
$incoming_email value is the mailbox that I am capturing mail from
and is valid since that is how this script gets triggered (via a
pipe from the email).

So - any really really smart readers out there have any idea why
one script using the same email code won't work?

It's possible that you're running into an SPF records/rules issue.

SPF records/rules are set up to indicate the authorized mail servers
for a domain. Technically, mail sent "from" that domain from any
other mail server is considered suspect/forged. The rules for a
domain indicate how the receiving mail server should handle messages
that fail the domain's SPF rules. The receiving mail server can
ignore these rules if they wish, but at the strict end of things,
the mail is rejected.

In your code you are taking mail from domain "A" and then resending
through your server. If there are strict SPF records in place for
domain "A" and your target server (the mail server for the "To:")
follows them, the messages will be rejected.

Because you are rewriting the "From:" to send from "A", rejects will
go back there, rather than to your hosting mailboxes.

You can ask "A" (the user on the "To:") if they are getting anything
back -- that's where most rejects would go, whether an SPF issue,
spam or something else. If they aren't, or if that doesn't shed
sufficient light, then you really need to talk with your hosting
provider to get them to look at their mail logs.

Assuming, as you do, that your code works, it is almost impossible
to debug mail delivery issues without more knowledge and access. The
non-delivery of a message tells you almost nothing (especially as in
your case where any bounces are likely to go to mailboxes you don't
seem to control). There are way too many moving parts in mail
deliver, and then the added issue of the redirection you're doing,
to do more than guess (as my SPF ides is) when the only known
element is "the mail goes to thin air".


     - Richard



The mailbox setup to pipe to my script is in domain B. The script runs and tries to send an email to a different mailbox in domain A with a From mailbox of the address that triggered the script (in domain B). The reply address is the same as the To address (in domain A). The two domains are on the same server - I think. Domain B is a subdomain of domain A (or 'add-on domain').

Again - this whole process works just fine for several other tasks that I perform with variations of this script. It is just this one mailbox (using all the same domains) that fails me.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux