该功能工作非常好,但在最后几天注意:fputs()[function.fputs]:发送8192个字节失败,errno = 32破坏的管道在/ cakeapp / trunk /注意:fputs()[function.fputs]:发送的49字节失败,errno = 32破坏的管道在第165行的
/cakeapp/trunk/app/controllers/components/email.php第169行
注意:fputs()[function.fputs]:发送6个字节失败,使用errno = 32第182行/cakeapp/trunk/app/controllers/components/email.php中的管道已损坏
我在Google中搜索一些建议,但是我的信息发现,谈到与Connection Time Outs有关的问题!
任何人可以建议一种方法来解决这个麻烦?
解决方案我有同样的问题,通过将协议设置为mail(共享)找到解决方案你不应该总是需要使用邮件作为协议,我在另一个网站中使用smtp作为协议,并且工作正常,但是我复制并粘贴了一些其他网站并且没有工作,所以我不得不把它改为'邮件')。我的示例配置看起来像这样(用你自己的凭据替换大写字母):
'protocol'=> 'mail','smtp_host'=> 'mail.YOUR_WEBSITE_DOMAIN.au','smtp_port'=> 25,'smtp_user'=> 'YOUR_EMAIL_ACCOUNT@YOUR_WEBSITE_DOMAIN.au','smtp_pass'=> 'YOUR_PASSWORD_FOR_YOUR_EMAIL_ACCOUNT','smtp_timeout'=> 5,//默认值'mailtype'=> 'html'// default:text
I wrote the next custom PHP function to send mail trough a SMTP MAIL SERVER.
function send($format = 'text'){ $smtpServer = 'mail.mymailserver.mx'; $port = '25'; $timeout = '60'; $username = 'myuser'; $password = 'mypassword'; $localhost = 'www.mydomain.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->from . $newLine ); fputs( $smtpConnect, 'RCPT TO: ' . $this->to . $newLine ); if( !empty( $this->cc ) ){ fputs( $smtpConnect, 'RCPT TO: ' . $this->cc . $newLine ); } if( !empty( $this->bcc ) ){ fputs( $smtpConnect, 'RCPT TO: ' . $this->bcc . $newLine ); } fputs( $smtpConnect, 'DATA' . $newLine ); fflush( $smtpConnect ); $raw = ""; $raw = @fread( $smtpConnect, 255 ) . "@"; $raw .= @fread( $smtpConnect, 255 ); fputs( $smtpConnect, 'To: ' . $this->to . $newLine ); fputs( $smtpConnect, 'From: <' . $this->from .'>' . $newLine ); fputs( $smtpConnect, 'Subject:' . $this->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->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->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->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; }The function was working very well, but in the last days I recived the nexts php errors:
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
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
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
I was searching in Google for some suggestions but the info that I found, talked about a problem related to Connection Time Outs !
Can Anyone suggest a way to fix this trouble ?
解决方案I had the same problem and found the solution by setting the protocol to 'mail' (of course this is not the case that always you need to use "mail" as protocol, I used "smtp" as protocol in another website, and was working fine, but the same code I copied and pasted for some other website and did not work, so I had to change it to 'mail'). My sample configuration looks like this(replace uppercase words with your own credentials):
'protocol' => 'mail', 'smtp_host' => 'mail.YOUR_WEBSITE_DOMAIN.au', 'smtp_port' => 25, 'smtp_user' => 'YOUR_EMAIL_ACCOUNT@YOUR_WEBSITE_DOMAIN.au', 'smtp_pass' => 'YOUR_PASSWORD_FOR_YOUR_EMAIL_ACCOUNT', 'smtp_timeout' => 5,// The default value 'mailtype' => 'html' //default: text
更多推荐
PHP自定义SMTP邮件功能返回ERROR fputs发送字节失败errno = 32破坏的管道
发布评论