By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,757 Members | 1,990 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,757 IT Pros & Developers. It's quick & easy.

mail() error handling

P: n/a

I use mail() for a musician's mailing list script that suddenly started
having problems after many months of working flawlessly. The code fragment
is:

if (mail($To,$Subject,$Body,$Headers,$Param))
{
print("The message was sent to:<p>$HTML_BCC<br><hr><h3>Completed
OK</h3><p>\n");
}
else
{
print("<font color=\"#ccff66\">There was a problem and the
message was probably not sent.</font><br>\n");
}
How can I find out what is causing the error? I thought there were
built-in error number and error description messages, but a search of the
manual at php.net does not come up with anything.

Pierre
--
Pierre Jelenc | H o m e O f f i c e R e c o r d s
| * Ethan Lipton * Marwood * The Cucumbers *
T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
www.thegigometer.com | www.homeofficerecords.com
Jul 17 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Hello,

On 12/02/2003 08:47 PM, Pierre Jelenc wrote:
I use mail() for a musician's mailing list script that suddenly started
having problems after many months of working flawlessly. The code fragment
is:

if (mail($To,$Subject,$Body,$Headers,$Param))
{
print("The message was sent to:<p>$HTML_BCC<br><hr><h3>Completed
OK</h3><p>\n");
}
else
{
print("<font color=\"#ccff66\">There was a problem and the
message was probably not sent.</font><br>\n");
}
How can I find out what is causing the error? I thought there were
built-in error number and error description messages, but a search of the
manual at php.net does not come up with anything.


The mail function will hardly give you any information. You would better
check the your mailer logs or send the messages directly to your
recipients SMTP server and see what it responds. In this case you may
want to try this class that comes with a subclass for interfacing with
the recipient SMTP server to perform direct deliveries.

http://www.phpclasses.org/mimemessage

You also need this:

http://www.phpclasses.org/smtpclass
--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #2

P: n/a
On 2003-12-02, Pierre Jelenc <rc**@panix.com> wrote:

I use mail() for a musician's mailing list script that suddenly started
having problems after many months of working flawlessly. The code fragment
is:
before the if put in this
echo "TO: $To SUBJECT: $Subject";

If it outputs "TO: SUBJECT: " then i think you're php version has
changed, and has register_globals=off now.
if (mail($To,$Subject,$Body,$Headers,$Param))

--
verum ipsum factum
Jul 17 '05 #3

P: n/a
Tim Van Wassenhove <eu**@pi.be> writes:
On 2003-12-02, Pierre Jelenc <rc**@panix.com> wrote:

I use mail() for a musician's mailing list script that suddenly started
having problems after many months of working flawlessly. The code fragment
is:


before the if put in this
echo "TO: $To SUBJECT: $Subject";

If it outputs "TO: SUBJECT: " then i think you're php version has
changed, and has register_globals=off now.
if (mail($To,$Subject,$Body,$Headers,$Param))


No, no problem there. In further tests we found that some of the mail does
go through sometimes, but in unpredictable manner. Unfortunately I don't
have access to the machine's configuration, it is a shared machine and to
reply to Manuel Lemos as well, we were told to use mail() and not attempt
to talk directly to sendmail (or I think qmail is what they use).

The mailing list is not terribly long, about 700 names that are all BCC'd,
and similar scripts on other hosts handle easily two thousand names.

Pierre
--
Pierre Jelenc | H o m e O f f i c e R e c o r d s
| * Ethan Lipton * Marwood * The Cucumbers *
T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
www.thegigometer.com | www.homeofficerecords.com
Jul 17 '05 #4

P: n/a
On 2003-12-03, Pierre Jelenc <rc**@panix.com> wrote:
The mailing list is not terribly long, about 700 names that are all BCC'd,
and similar scripts on other hosts handle easily two thousand names.


Most ISPs don't accept mails with +500 bcc addresses.

Without access to /var/log/mail.(log|warn|error) it is hard to tell what
is going wrong.

--
verum ipsum factum
Jul 17 '05 #5

P: n/a
Tim Van Wassenhove <eu**@pi.be> writes:
On 2003-12-03, Pierre Jelenc <rc**@panix.com> wrote:
The mailing list is not terribly long, about 700 names that are all BCC'd,
and similar scripts on other hosts handle easily two thousand names.
Most ISPs don't accept mails with +500 bcc addresses.


This one does, it is actually a music-related company that offers cheap
web sites for poor musicians, and it does not put limits on the number of
addressees; each musician is known personally by the owners.
Without access to /var/log/mail.(log|warn|error) it is hard to tell what
is going wrong.


OK, I'll try to have them look at it and tell me if they see something.

Thanks,

Pierre
--
Pierre Jelenc | H o m e O f f i c e R e c o r d s
| * Ethan Lipton * Marwood * The Cucumbers *
T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
www.thegigometer.com | www.homeofficerecords.com
Jul 17 '05 #6

P: n/a
Hello,

On 12/03/2003 09:06 PM, Pierre Jelenc wrote:
I use mail() for a musician's mailing list script that suddenly started
having problems after many months of working flawlessly. The code fragment
is:


before the if put in this
echo "TO: $To SUBJECT: $Subject";

If it outputs "TO: SUBJECT: " then i think you're php version has
changed, and has register_globals=off now.

if (mail($To,$Subject,$Body,$Headers,$Param))

No, no problem there. In further tests we found that some of the mail does
go through sometimes, but in unpredictable manner. Unfortunately I don't
have access to the machine's configuration, it is a shared machine and to
reply to Manuel Lemos as well, we were told to use mail() and not attempt
to talk directly to sendmail (or I think qmail is what they use).


I do not know why you were told to do that because internally that is
exactly what the mail() function implementation does, ie, either
communicate directlty to the sendmail or qmail programs.

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #7

P: n/a
Manuel Lemos <ml****@acm.org> writes:

I do not know why you were told to do that because internally that is
exactly what the mail() function implementation does, ie, either
communicate directlty to the sendmail or qmail programs.


I know, but this is a situation with people doing favors for other people
on systems that are working OK but without full-time tech staff, and once
they have something working (Ah! So they thought....) they don't want
anyone going beyond the fence.

Inspection of the logs shows what happened: Apparently, while going
through its BCC list, qmail encountered a non-responsive server. Instead
of skipping the problematic address and dealing with the others, it kept
retrying, and timed out.

What I don't understand is why qmail did not return "success" to mail()
once it had received all the data, *then* tried to deliver the mail. I
assume it's something that can be configured somewhere, as well as the odd
behavior of not skipping an address that is giving trouble, but it's out
of my reach.

Pierre
--
Pierre Jelenc | H o m e O f f i c e R e c o r d s
| * Ethan Lipton * Marwood * The Cucumbers *
T h e G i g o m e t e r | * Switchblade Kittens * Pawnshop *
www.thegigometer.com | www.homeofficerecords.com
Jul 17 '05 #8

P: n/a
Hello,

On 12/06/2003 05:18 PM, Pierre Jelenc wrote:
I do not know why you were told to do that because internally that is
exactly what the mail() function implementation does, ie, either
communicate directlty to the sendmail or qmail programs.

I know, but this is a situation with people doing favors for other people
on systems that are working OK but without full-time tech staff, and once
they have something working (Ah! So they thought....) they don't want
anyone going beyond the fence.


I think you are not understanding what is communicating directly with
sendmail or qmail. You do not have to change anything in your server. It
is just executing those programs like the mail() function does. I think
you are just fearing the unknown.

Inspection of the logs shows what happened: Apparently, while going
through its BCC list, qmail encountered a non-responsive server. Instead
of skipping the problematic address and dealing with the others, it kept
retrying, and timed out.
qmail does not do that. I think you are confused. Once you queue a
message with many Bcc: recipients, it will try to deliver the message to
many of them simultaneously upto to a limit of simultaneous deliveries.

All messages sent to addresses with delivery problems will make the
message stay in the queue for a while but that does not stop deliveries
of the same message or other message to other addresses.
What I don't understand is why qmail did not return "success" to mail()
once it had received all the data, *then* tried to deliver the mail. I
assume it's something that can be configured somewhere, as well as the odd
behavior of not skipping an address that is giving trouble, but it's out
of my reach.


qmail does not try to deliver messages immediately. You just queue the
message and it will try to delivery whenever it is possible. So, it
should always return success unless you have formatting problems that
make the qmail program fail and not queue any message at all.

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.