Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Custom SMTP Mail function Return ERROR fputs send bytes failed errno=32 Broken pipe
    text
    copied!<p>I wrote the next custom PHP function to send mail trough a SMTP MAIL SERVER.</p> <pre><code>function send($format = 'text'){ $smtpServer = 'mail.mymailserver.com.mx'; $port = '25'; $timeout = '60'; $username = 'myuser'; $password = 'mypassword'; $localhost = 'www.mydomain.com.mx'; $newLine = "\r\n"; $smtpConnect = fsockopen( $smtpServer, $port, $errno, $errstr, $timeout ); fputs( $smtpConnect,'AUTH LOGIN'.$newLine ); fputs( $smtpConnect, base64_encode( $username ) . $newLine ); fputs( $smtpConnect, base64_encode( $password ) . $newLine ); fputs( $smtpConnect, 'HELO ' . $localhost . $newLine ); fputs( $smtpConnect, 'MAIL FROM: ' . $this-&gt;from . $newLine ); fputs( $smtpConnect, 'RCPT TO: ' . $this-&gt;to . $newLine ); if( !empty( $this-&gt;cc ) ){ fputs( $smtpConnect, 'RCPT TO: ' . $this-&gt;cc . $newLine ); } if( !empty( $this-&gt;bcc ) ){ fputs( $smtpConnect, 'RCPT TO: ' . $this-&gt;bcc . $newLine ); } fputs( $smtpConnect, 'DATA' . $newLine ); fflush( $smtpConnect ); $raw = ""; $raw = @fread( $smtpConnect, 255 ) . "@"; $raw .= @fread( $smtpConnect, 255 ); fputs( $smtpConnect, 'To: ' . $this-&gt;to . $newLine ); fputs( $smtpConnect, 'From: &lt;' . $this-&gt;from .'&gt;' . $newLine ); fputs( $smtpConnect, 'Subject:' . $this-&gt;subject . $newLine ); $format = 'html'; if( $format == 'text' ){ $headers = "Content-Type: text/plain; charset=\"iso-8859-1\"" . "\r\n"; $headers .= "Content-Transfer-Encoding: 7bit" . "\r\n"; $message = $this-&gt;bodyText(); fputs( $smtpConnect, $headers . $newLine . $newLine ); fputs( $smtpConnect, $message . $newLine . '.' . $newLine ); }else{ $random_hash = md5(date('r', time())); $headers = "Content-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\"\r\n"; $headers .= "--PHP-alt-" . $random_hash . "\r\n"; $headers .= "Content-Type: text/plain; charset=\"iso-8859-1\"" . "\r\n"; $headers .= "Content-Transfer-Encoding: 7bit" . "\r\n"; $message = $this-&gt;bodyText(); fputs( $smtpConnect, $headers . $newLine ); fputs( $smtpConnect, $message . $newLine ); $headers = "--PHP-alt-" . $random_hash . "\r\n"; $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"" . "\r\n"; $headers .= "Content-Transfer-Encoding: 7bit" . "\r\n"; $message = $this-&gt;bodyHtml(); fputs( $smtpConnect, $headers . $newLine ); fputs( $smtpConnect, $message . $newLine ); $headers = "--PHP-alt-" . $random_hash . "--\r\n"; fputs( $smtpConnect, $headers . '.' . $newLine ); } fputs( $smtpConnect,'QUIT' . $newLine ); return true; } </code></pre> <p>The function was working very well, but in the last days I recived the nexts php errors:</p> <p>Notice: fputs() [function.fputs]: send of 8192 bytes failed with errno=32 Broken pipe in /cakeapp/trunk/app/controllers/components/email.php on line 165</p> <p>Notice: fputs() [function.fputs]: send of 49 bytes failed with errno=32 Broken pipe in /cakeapp/trunk/app/controllers/components/email.php on line 169</p> <p>Notice: fputs() [function.fputs]: send of 6 bytes failed with errno=32 Broken pipe in /cakeapp/trunk/app/controllers/components/email.php on line 182</p> <p>I was searching in Google for some suggestions but the info that I found, talked about a problem related to Connection Time Outs !</p> <p>Can Anyone suggest a way to fix this trouble ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload