Re: mail() doesn't work

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

 



On 9/13/2014 12:27 PM, Robert Cummings wrote:
On 14-09-13 12:20 PM, Jim Giner wrote:
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?

Hi Jim, the mail() function returns true if the message is "accepted for
delivery" and doesn't provide any information about whether it actually
gets sent out. If you are receiving a return status code of true, then
the mail server accepted it. So if you aren't receiving it on the other
end then I would investigate the mail server logs.

You've said the script works in other places, are these on the same
server where you are having problems? Is the target mail server the same
in all cases?

Cheers,
Rob.
It's all my same domain on a shared host. My provider says there is no problem with the emailbox. I can send emails manually to it and they are received no problem. The other scripts differ in that they are triggered by mail coming to a different address. They look for different things in the emails but then they send an email result to the same mailbox and work just fine. I suspect it is something I am doing in this particular script since that is the only variable. I just can't find it. I have php error checking on; I post error log messages throughout. No indications at all.

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