[nycphp-talk] smtp socket error that i just don't get
Hans Zaunere
hans at nyphp.org
Fri Nov 7 18:41:30 EST 2003
Mark Armendariz wrote:
> Hello all,
>
> I'm hoping you guys can lend a hand... Below is some code I grabbed from
> the manual (http://www.php.net/manual/en/ref.mail.php) for sending mail
> directly through the socket rather than using the mail command. Now it
> works well on my server, but when I installed it on my client's server,
> I get an endless loop of errors like so:
>
> *Notice*: fputs(): send of 41 bytes failed with errno=32 Broken pipe in
> */usr/local/etc/httpd/htdocs/bostonindoorgames/admin/mailer.php* on line
> *136*
>
> *Notice*: fputs(): send of 42 bytes failed with errno=32 Broken pipe in
> */usr/local/etc/httpd/htdocs/bostonindoorgames/admin/mailer.php* on line
> *136*
>
> The code is below, and line 136 is right under the comment // --------
> PROBLEM STARTS HERE!!! ----------------
>
> Now, as I mentioned, this same code works on my server just fine. There
> is surrounding code, but it's all involved in setting the vars and such
> for the email itself. I assure you all vars are set properly, as I've
> checked them at least 6 times. I thought that there may possibly be
> some kind of socket issue, but then wouldn't it have a problem
> connecting to the socket in the first place? Or even sending the HELO
> command after the connect?
>
> When searching for the error, I came up with this (which is a ll
> gibberish to me):
>
> Broken pipe
> ===========
>
> This condition is often normal, and the message is merely
> informational (as when piping many lines to the head program).
> The condition occurs when a write on a pipe does not find a
> reading process. This usually generates a signal to the executing
> program, but this message displays when the program ignores the
> signal.
>
> Check the process at the end of the pipe to see why it exited.
>
> The symbolic name forthis error is EPIPE, errno=32.
>
>
>
> // Open socket to SMTP server
> $connect = fsockopen (ini_get('SMTP'), ini_get('smtp_port'), $errno,
> $errstr, 30) or die('Could not talk to the sendmail server!');
> $rcv = fgets($connect, 1024);
The mail server is probably not liking something about what you're sending it; either here, or later in the code. I'd begin to replace the simple: $rcv = fgets($connect, 1024); with some debugging that prints what the actual mail server's response is, for instance:
$rcv = fgets($connect, 1024);
trigger_error($rcv);
Add this each time you try to send something to the mail server and see if it's having a problem.
H
More information about the talk
mailing list