473,390 Members | 1,176 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,390 software developers and data experts.

mail() error handling


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
8 52078
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
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
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Dave | last post by:
Hello all, I found Herb Sutter's article regarding error handling in the most recent CUJ to be very, very good. However, in trying to apply what I learned from the article, I am left with some...
8
by: Erencans | last post by:
Hi to all, I want to error handling in ASP. But i think that ASP is not enough for error handling. I have got two chance. 1. I can prapare an error page and control throught IIS. 2. I can use on...
2
by: Max | last post by:
Sometimes I get this error when testing web.mail: The server rejected one or more recipient addresses The server response was: 473 kjhg@Kjhg.com relaying prohibited. You should authenticate first...
5
by: Lau Lei Cheong | last post by:
Hello, I'm currently using Application_Error method in Global.asax.cs to handle errors. Recently, I heard about Page.ErrorPage and plan to use it for handling errors on certain pages. Are...
10
by: Justin Dutoit | last post by:
Hey. I'm still not experienced at error handling, and I need to know if Try.. Catch blocks are meant to be used to handle errors in your own app, ie bugs. Or, are they only for external things like...
4
by: Al Williams | last post by:
Hi, I have error handling in place throughout my application. I also start the application wrapped in error handling code to catch any unexpected exceptions (i.e. exceptions that occur where I...
3
by: dgiagio | last post by:
Hi, I'm creating a SMTP application and I would like to hear opinions about error handling. Currently there are two functions that communicate with the remote peer: ssize_t...
4
by: Johnny Jörgensen | last post by:
Hi Does anyone know of a component that can facilitate error handling in a complex application. What I'm looking for is a component you can simply drop on your application form (or the like)....
9
by: arnuld | last post by:
Can anyone point me to some online/offline document on error handling in C ? I am doing some Socket Programming in C and feeling a lots of difficult in error handling :( Also some time ago...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.