Re: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-10 Thread Dave M G

Peter, Bob,

Thank you for replying.

After a few days testing, I set up an error handler for when messages 
don't get sent. I started to see an error saying Language String failed 
to load, which seems to be particular to the PHPmailer scripts I am using.


Long story short, after some searching on the web, it looks like the 
sending of mails will die if one mail on the list is invalid.


I tried sending a message out to the list, got back a response saying 
that the recipient did not exist. So I deleted that user, and then the 
mail went through fine on the next attempt.


I'm a little fuzzy on what exactly is happening.

Does the PHP mail() command (and by extension, classes built upon it) 
listen for responses from the server it is sending to?


--
Dave M G

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



RE: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-09 Thread Bob McConnell
From: Dave M G

 There is one other possibility. According to the RFCs, the standard
line
 ending for email is CRLF. Make sure your system is sending both
 characters after each line. There is a slim chance the server is
cutting
 you off after some number of bytes if you are only sending a LF.
 
 This is actually a possiblity. I think I might be only using LF.
 
 Some of the text being sent in the emails is entered via a form on a
web 
 page. Is it possible to enforce CRLF on that text?

You would have to scan the text when you process the form and replace
any bare LF you find with CRLF. The string sequence for that would be
\r\n. It shouldn't be too difficult to come up with a regular
expression to find any LF not preceded by a CR and replace it.

Also, check your mail library to make sure it defines $EOL correctly as
well. I reported that as a bug in PHPMailer a while back. If it is
correct, it may actually fix the bare LF's for you.

Bob McConnell

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



RE: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-08 Thread Bob McConnell
From: Dave M G

 I have a set of scripts that sends out emails to a list of about 150 
 people. Sometimes it works fine.
 
 Other times, it dies part way through the list, and in my error logs I

 get this output:
 
 fputs() [a href='function.fputs'function.fputs/a]: send of 22
bytes 
 failed with errno=32 Broken pipe /public_html/class.smtp.php 489
 
 The code that sends the mail is derived from here:
 http://www.phpclasses.org/browse/file/920.html
 
 It's mostly rock solid code, so far as I know, so I suspect the
problem 
 to more with my server settings or something.
 
 That said, I don't know what differentiates a failed mailing and a 
 successful one.
 
 After a Google search, it seems broken pipes are a matter of time 
 outs. That's about as far as I understand it, though.
 
 Can anyone throw me a tip as to how I might diagnose this problem?

Broken pipe is a euphemism for Network error. There are any number
of causes including the remote server closing the socket, a switch or
hub between here and there is bogged down by backup traffic, or a
segment your connection passes through became too busy with higher
priority video traffic. The actual details are difficult to determine
and none of the administrators involved will ever admit they had a
problem. In most cases the TCP/IP error will simply tell you it timed
out waiting for a response. Your code should be able to re-open the
connection at this point and resend the message that triggered the
error. Then resume working on the rest of your list.

Bob McConnell

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



Re: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-08 Thread a...@ashleysheridan.co.uk
Could it be that there are connection limits on the remote server?

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: Bob McConnell r...@cbord.com
Date: Wed, Sep 8, 2010 18:24
Subject: [PHP] Broken pipes, time outs, PHP, and mail
To: php-general@lists.php.net

From: Dave M G

 I have a set of scripts that sends out emails to a list of about 150 
 people. Sometimes it works fine.
 
 Other times, it dies part way through the list, and in my error logs I

 get this output:
 
 fputs() [a href='function.fputs'function.fputs/a]: send of 22
bytes 
 failed with errno=32 Broken pipe /public_html/class.smtp.php 489
 
 The code that sends the mail is derived from here:
 http://www.phpclasses.org/browse/file/920.html
 
 It's mostly rock solid code, so far as I know, so I suspect the
problem 
 to more with my server settings or something.
 
 That said, I don't know what differentiates a failed mailing and a 
 successful one.
 
 After a Google search, it seems broken pipes are a matter of time 
 outs. That's about as far as I understand it, though.
 
 Can anyone throw me a tip as to how I might diagnose this problem?

Broken pipe is a euphemism for Network error. There are any number
of causes including the remote server closing the socket, a switch or
hub between here and there is bogged down by backup traffic, or a
segment your connection passes through became too busy with higher
priority video traffic. The actual details are difficult to determine
and none of the administrators involved will ever admit they had a
problem. In most cases the TCP/IP error will simply tell you it timed
out waiting for a response. Your code should be able to re-open the
connection at this point and resend the message that triggered the
error. Then resume working on the rest of your list.

Bob McConnell

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



Re: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-08 Thread Dave M G

Bob,

Thank you for replying.


Your code should be able to re-open the
connection at this point and resend the message that triggered the
error. Then resume working on the rest of your list.


Unfortunately, it seems that this is not happening. The loop that sends 
out individual mail dies, and the remaining mails stop being sent.


Is there perhaps some way I can force the PHP code to ignore the one 
mailing that failed and continue with the rest?


--
Dave M G

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



Re: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-08 Thread a...@ashleysheridan.co.uk
In order to help we really need to have a look at the code in question. You say 
the code is derived from another class you downloaded. Are you able to post the 
important bits of it in an email, or put it all on a pastebin?

Thanks,
Ash
http://www.ashleysheridan.co.uk

- Reply message -
From: Dave M G mar...@autotelic.com
Date: Wed, Sep 8, 2010 18:45
Subject: [PHP] Broken pipes, time outs, PHP, and mail
To: php-general@lists.php.net

Bob,

Thank you for replying.

 Your code should be able to re-open the
 connection at this point and resend the message that triggered the
 error. Then resume working on the rest of your list.

Unfortunately, it seems that this is not happening. The loop that sends 
out individual mail dies, and the remaining mails stop being sent.

Is there perhaps some way I can force the PHP code to ignore the one 
mailing that failed and continue with the rest?

-- 
Dave M G

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



RE: Re: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-08 Thread Bob McConnell
From: a...@ashleysheridan.co.uk

 Could it be that there are connection limits on the remote server?
 
 Thanks,
 Ash

Only if you are opening a new connection for each message. Any decent
SMTP client should be able to send multiple messages over a single
connection.

You could capture the traffic with Wireshark. Set the capture filter to
only grab SMTP traffic to that server's IP address. Unless it is going
through SSL/TLS, you can read the handshake messages. They will look
something like this:

-8
220 lists.php.net ESMTP Postfix
EHLO ashleysheridan.co.uk
250-mail.php.net
250-PIPELINING
250-SIZE 1024
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250 8BITMIME
MAIL FROM:a...@ashleysheridan.co.uk
250 Ok
RCPT TO:php-general@lists.php.net
250 Ok
-8

The lines beginning with numbers are the server's responses. All of them
should be ASCII/UTF-8 text.

There is one other possibility. According to the RFCs, the standard line
ending for email is CRLF. Make sure your system is sending both
characters after each line. There is a slim chance the server is cutting
you off after some number of bytes if you are only sending a LF.

Bob McConnell

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



Re: [PHP] Broken pipes, time outs, PHP, and mail

2010-09-08 Thread Dave M G

Ash, Bob,

Thank you for replying.


There is one other possibility. According to the RFCs, the standard line
ending for email is CRLF. Make sure your system is sending both
characters after each line. There is a slim chance the server is cutting
you off after some number of bytes if you are only sending a LF.


This is actually a possiblity. I think I might be only using LF.

Some of the text being sent in the emails is entered via a form on a web 
page. Is it possible to enforce CRLF on that text?


--
Dave M G

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