PHP Benutzerdefinierte SMTP-E-Mail-Funktion gibt einen FEHLER Zurück senden fputs bytes failed errno=32 Broken pipe

Schrieb ich die nächste eigene PHP Funktion zum senden von Mails durch einen SMTP-MAIL-SERVER.

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->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;

}

Wurde die Funktion arbeitet sehr gut, aber in den letzten Tagen habe ich recived der nächsten php-Fehler:

Hinweis: fputs() [function.fputs]: senden von 8192 bytes failed with errno=32 Broken pipe in /cakeapp/trunk/app/controllers/components/email.php on line 165

Hinweis: fputs() [function.fputs]: senden von 49 bytes failed with errno=32 Broken pipe in /cakeapp/trunk/app/controllers/components/email.php on line 169

Hinweis: fputs() [function.fputs]: senden von 6 bytes failed with errno=32 Broken pipe in /cakeapp/trunk/app/controllers/components/email.php on line 182

War ich auf der Suche in Google für einige Vorschläge, aber die info, die ich gefunden habe, Sprachen von einem problem im Zusammenhang mit dem Anschluss Time-Outs !

Kann Jeder jeden schlagen einen Weg, das zu beheben diese Probleme ?

versuchen Sie, diese Klasse: pastebin.com/e1RiPj6P ich benutze es in jedem Projekt.
Ich Teste gerade mit dem Wert der Variable $timeout, werde ich erhöhen, von 60 Sekunden bis zu 90. Scheint, dass diese änderung das problem beheben, ich werde warten, mehr Zeit vor um diesen Beitrag zu schließen : )
Dieses problem wird auch sichtbar mit Zend_Mail-Komponente und gar nicht einzigartig auf dieser benutzerdefinierte E-mail-Funktion.

InformationsquelleAutor Edwin Sandoval | 2010-12-02

Schreibe einen Kommentar