Problems with Phpmailer and large emails

Asked

Viewed 142 times

2

I have a problem with sending emails from an application.

I’ve already tried PEAR_Mail together with PEAR_Mail_Mime and now with PHPMailer (what I found most readable).

What is going on?

When I send an alert email (usually messages of about 80 characters) the email is sent without problems. But when I went to test it with a 1000-character email, the feedback I get is:

2014-06-17 14:35:06     Connection: opened
2014-06-17 14:35:06     SERVER -> CLIENT: 220 _____ ESMTP
2014-06-17 14:35:06     CLIENT -> SERVER: EHLO _____
2014-06-17 14:35:06     SERVER -> CLIENT: 250-_____
250-PIPELINING
250-8BITMIME
250-SIZE 31457280
250 AUTH LOGIN PLAIN
2014-06-17 14:35:06     CLIENT -> SERVER: AUTH LOGIN
2014-06-17 14:35:06     SERVER -> CLIENT: 334 ___
2014-06-17 14:35:06     CLIENT -> SERVER: (*      *)
2014-06-17 14:35:06     SERVER -> CLIENT: 334 ___
2014-06-17 14:35:06     CLIENT -> SERVER: (*      *)
2014-06-17 14:35:07     SERVER -> CLIENT: 235 ok, go ahead (#2.0.0)
2014-06-17 14:35:07     CLIENT -> SERVER: MAIL FROM:<_____>
2014-06-17 14:35:07     SERVER -> CLIENT: 250 ok
2014-06-17 14:35:07     CLIENT -> SERVER: RCPT TO:<_____>
2014-06-17 14:35:07     SERVER -> CLIENT: 250 ok
2014-06-17 14:35:07     CLIENT -> SERVER: DATA
2014-06-17 14:35:07     SERVER -> CLIENT: 354 go ahead
2014-06-17 14:35:07     CLIENT -> SERVER: Date: Tue, 17 Jun 2014 11:35:06 -0300
2014-06-17 14:35:07     CLIENT -> SERVER: To: ______
2014-06-17 14:35:07     CLIENT -> SERVER: From: ______
2014-06-17 14:35:07     CLIENT -> SERVER: Subject: =?iso-8859-1?Q?[______]_1_erro_|_Renova=E7=E3o_autom=E1tica?=
2014-06-17 14:35:07     CLIENT -> SERVER: Message-ID: <____@_______>
2014-06-17 14:35:07     CLIENT -> SERVER: X-Priority: 3
2014-06-17 14:35:07     CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.8 (https://github.com/PHPMailer/PHPMailer/)
2014-06-17 14:35:07     CLIENT -> SERVER: MIME-Version: 1.0
2014-06-17 14:35:07     CLIENT -> SERVER: Content-Type: text/plain; charset=iso-8859-1
2014-06-17 14:35:07     CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2014-06-17 14:35:07     CLIENT -> SERVER:
2014-06-17 14:35:07     CLIENT -> SERVER: Segue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=
2014-06-17 14:35:07     CLIENT -> SERVER: =E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:=
2014-06-17 14:35:07     CLIENT -> SERVER: 35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da =
2014-06-17 14:35:07     CLIENT -> SERVER: renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-=
2014-06-17 14:35:07     CLIENT -> SERVER: 17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o l=
2014-06-17 14:35:07     CLIENT -> SERVER: og da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 20=
2014-06-17 14:35:07     CLIENT -> SERVER: 14-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASeg=
2014-06-17 14:35:07     CLIENT -> SERVER: ue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=
2014-06-17 14:35:07     CLIENT -> SERVER: =E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:=
2014-06-17 14:35:07     CLIENT -> SERVER: 06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da ren=
2014-06-17 14:35:07     CLIENT -> SERVER: ova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 =
2014-06-17 14:35:07     CLIENT -> SERVER: 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log =
2014-06-17 14:35:07     CLIENT -> SERVER: da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-=
2014-06-17 14:35:07     CLIENT -> SERVER: 06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue =
2014-06-17 14:35:07     CLIENT -> SERVER: o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o:=
2014-06-17 14:35:07     CLIENT -> SERVER:  2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0A=
2014-06-17 14:35:07     CLIENT -> SERVER: Segue o log da renova=E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=
2014-06-17 14:35:07     CLIENT -> SERVER: =E7=E3o: 2014-06-17 11:35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:=
2014-06-17 14:35:07     CLIENT -> SERVER: 35:06=0ASegue o log da renova=E7=E3o: 2014-06-17 11:35:06=0A=0AContrato: 22=
2014-06-17 14:35:07     CLIENT -> SERVER: 0760 - =DAltimo lancamento n=E3o encontrado
2014-06-17 14:35:07     CLIENT -> SERVER:
2014-06-17 14:35:07     CLIENT -> SERVER: .
2014-06-17 14:35:17     SERVER -> CLIENT:
2014-06-17 14:35:17     SMTP ERROR: DATA END command failed:
SMTP Error: data not accepted.
Message could not be sent.Mailer Error: SMTP Error: data not accepted.2014-06-17 14:35:17       CLIENT -> SERVER: QUIT
2014-06-17 14:35:27     SERVER -> CLIENT:
2014-06-17 14:35:27     SMTP ERROR: QUIT command failed:
2014-06-17 14:35:27     Connection: closed

Although the server specifies:

250-8BITMIME

I tested forcing Base64, and I had the same problem.

The code I’m using to perform this request is:

    $mail = new PHPMailer();
    $mail->isSMTP();
    $mail->Host = $host;
    $mail->Port = $port;
    $mail->SMTPAuth = true;
    $mail->Username = $username;
    $mail->Password = $password;
    $mail->From = $username;
    $mail->FromName = "________";
    $mail->addAddress($to);

    $mail->isHTML(false);

    $mail->Subject = $this->_subject;
    //$mail->msgHTML($this->_htmlMessage); estou tentando inicialmente apenas com texto

    $mail->Body = $mail->encodeString($this->_txtMessage, 'quoted-printable');
    $mail->SMTPDebug = 3;

            //$mail->Encoding = '8bit'; //ja tentei deixar explicito, ja tentei base64
            //$mail->CharSet = 'utf8'; //ja tentei deixar sem, deixar utf8 e iso8859-1
    if (!$mail->send()){
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
        return false;
    }else{
        return true;
    }

At information level, this is the end of the return of a small email sent from the same code:

2014-06-17 14:47:03     CLIENT -> SERVER:
2014-06-17 14:47:03     CLIENT -> SERVER: .
2014-06-17 14:47:03     SERVER -> CLIENT: 250 ok 1403016424 qp 30696
2014-06-17 14:47:03     CLIENT -> SERVER: QUIT
2014-06-17 14:47:03     SERVER -> CLIENT: 221 ______
2014-06-17 14:47:03     Connection: closed
  • Test: http://swiftmailer.org

2 answers

1


I was able to send the big messages using: http://swiftmailer.org/

I still haven’t thoroughly checked what happened, and what he sends to the server. So the solution to the problem was to change from Pear_mail / Phpmailer to swiftmailer.

Thank you all for your help.

1

The $mail->Body with a minimal amount in Kb failure and gives problems.

Try to convey the message as follows:

$mail->MsgHTML($this->_txtMessage);

and/or also:

$mail->AltBody = $this->_txtMessage;

User response credits @user2270404 in this answer in the SOEN.

  • thanks first for the help, but still with the same problem, but now it creates a part of the HTML message and another only text.

  • @Rodrigochaves Yes, Msghtml is the HTML component that follows in email, Altbody is the "alternative text" component without HTML for programs whose HTML support is disabled or non-existent.

  • @Rodrigochaves Is the username email? If so, the server may require $mail->Username is equal to $mail->From.

  • $mail->Username already equals $mail->From. But I believe that if it was that I could not even send small messages, I tried to set also with: $mail->setFrom($username, $username); But nothing yet :(

  • @Rodrigochaves Have you exceeded the daily quota? Do you need to specify the authentication protocol through the $mail->SMTPSecure = "ssl"; or tls or another?

  • @Rodrigochaves A more likely cause may be the timeout of the operation, experiment $mail->Timeout = 60; by default I think to be 10.

  • regarding tls, ssl. If the server is specified it does not connect, but I tried it on another server with tls and the same problem occurred. This other server have access to postfix logs, but did not report anything unusual beyond the connections.

  • @chavesfop Did you see the question I was talking about Timeout? I think it’s the last thing I could think of :/

  • Same problem, but now displays at the end a server timeout message. :/

  • @chavesfop Teve timeout with 60 seconds? Is the server not "mired" working at this time?

  • one of the servers I manage, the email queue is usually empty. But even so the SMTP would queue the sending message in the postfix if the queue was large, no?

  • One thing is pretty obvious, small message works, big message doesn’t work :/

Show 7 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.