#113 new
Milan Vasic

Quoted-Printable, Soft Line Breaks problem

Reported by Milan Vasic | November 4th, 2009 @ 07:04 AM

Hi,

I'm using a Quoted-Printable encoding type, and if I have a URL in my email body, with for example
www.milanvasic.com/test/test.jpg , surround with HTML, and if 76 character is dot '.' the SWIFT replace it with equal and break the line, that's correct but the problem is in new line SWIFT add one more dot, and on users side we have a wrong URL's with two dots, like www.milanvasic..com/test/test.jpg.

Regards,
Milan

P.S.

some header details
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Comments and changes to this ticket

  • Milan Vasic

    Milan Vasic November 4th, 2009 @ 07:06 AM

    Our SWIFT version is 3.3.2.

  • xdecock

    xdecock November 6th, 2009 @ 08:31 AM

    wow, old version, however, i had this problem with some mail servers sometime ago so, are you sure it's swift's fault?

    can you provide a sample code?

    what transport are you using?

    (However, the best way will probably be to either update to 3.3.3 or to switch to 4.0.5)

  • Milan Vasic

    Milan Vasic December 9th, 2009 @ 03:23 AM

    We use default transport, also simple code

        $message = new Swift_Message("$subject", "$txt_message");
        $message->attach(new Swift_Message_Part($html_message, "text/html"));
    
        .....
    
        $swift->send($message, $recipients, $sender);
    

    it absolutely usual, I was search and read some specification about "qp" encoding, and it looks like that from some reason '.' at the end of line you replace with two '..' and that break our links.

  • xdecock

    xdecock December 9th, 2009 @ 03:29 AM

    Can you please check your smtp server? and manually send one mail (by
    telnet) with a . at the end of the line (altough it's only if the . is the
    first element of the line that we double it as the smtp protocol requires
    it).

    I had the problem with a dspam setup, and this was not caused by
    swiftmailer.

    Xavier De Cock

  • Fabien Potencier

    Fabien Potencier January 5th, 2010 @ 06:59 PM

    Any feedback on this issue?

  • softjury

    softjury May 17th, 2010 @ 08:44 PM

    • → Tag changed from mime, quoted-printable to dots, mime, quoted-printable, sendmail, setwritetranslations

    Hi there,

    the problem is still there in 4.0.6 release.

    The problem is with handling of lines beginning with a dot.

    require_once('Swift-4.0.6/lib/swift_required.php');
    
    function TestCase($sendmail)
    {
            $mailer = Swift_Mailer::newInstance(Swift_SendmailTransport::newInstance($sendmail));
    
            $message = Swift_Message::newInstance("Sent via $sendmail")
                        ->setFrom(array('from@example.com' => 'Mr. Sender'))
                        ->setTo  (array('to@example.com'   => 'Mr. Recipient'))
                        ->setBody(".", 'text/plain');
    
            $mailer->send($message);
    }
    
    TestCase('/usr/sbin/sendmail -t');
    TestCase('/usr/sbin/sendmail -bs');
    
    Message-ID: <1274091537.4bf11811891b2@swift.generated>
    Date: Mon, 17 May 2010 12:18:57 +0200
    Subject: Sent via /usr/sbin/sendmail -t
    From: "Mr. Sender" <from@example.com>
    To: "Mr. Recipient" <to@example.com>
    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: quoted-printable
    
    ..
    
    Message-ID: <1274091537.4bf11811aa04f@swift.generated>
    Date: Mon, 17 May 2010 12:18:57 +0200
    Subject: Sent via /usr/sbin/sendmail -bs
    From: "Mr. Sender" <from@example.com>
    To: "Mr. Recipient" <to@example.com>
    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: quoted-printable
    
    .
    

    I suspect the following code being responsible for this:

    Swift-4.0.6/lib/classes/Swift/Transport/SendmailTransport.php

    $buffer->setWriteTranslations(array("\r\n" => "\n", "\n." => "\n.."));
    

    Swift-4.0.6/lib/classes/Swift/Transport/AbstractSmtpTransport.php

    $this->_buffer->setWriteTranslations(array("\r\n." => "\r\n.."));
    

    Email from production system (symfony 1.4.4 with bundled swiftmailer)

    [..]
    foo baz</th><td>&nbsp;<a href=3D"https://backoffice=
    ..example.com/rating_comment/newRatingComments">Activate</a></td></tr=
    [..]
    

    This is a major show stopper since links in html emails, as reported by Milan Vasic, are broken because of this bug.

  • Chris Corbyn

    Chris Corbyn May 21st, 2010 @ 09:45 AM

    You guys should be adding "-i" to your sendmail commands. Without it Swift Mailer needs to double the dots up, but it appears that whatever sendmail wrapper you have it does not conform to the behaviour documented for sendmail, as copied by exim and postfix. Adding the -i flag will make the problem go away.

  • softjury

    softjury May 21st, 2010 @ 06:55 PM

    I confirm using

    /usr/sbin/sendmail -t -i
    

    fixes the double dot problem.

    Just pushing this workaround in our symfony projects' factories.yml's.

    Thanks, Chris!

  • softjury

    softjury May 21st, 2010 @ 06:56 PM

    BTW: We're using postfix 2.5.x

  • Milan Vasic

    Milan Vasic December 23rd, 2010 @ 04:11 AM

    I was add additional check for all URL's, just before, we send email put, newest version 4.0.6 is much better than previous.

  • Milan Vasic

    Milan Vasic June 1st, 2011 @ 03:36 AM

    Still have this issue on SWIFT 4.0.6, any ideas what should be done there to make it works?

  • Milan Vasic

    Milan Vasic June 1st, 2011 @ 03:42 AM

    Also I found this one

    public function send(Swift_Mime_Message $message, &$failedRecipients = null) {

    $failedRecipients = (array) $failedRecipients;
    
    if ($evt = $this->_eventDispatcher->createSendEvent($this, $message))
    {
    

    in MailTransport.ph and SendMailTransport.php

    this is not correct to be in if clause

    $evt = $this->_eventDispatcher->createSendEvent($this, $message)

    should be

    $evt == $this->_eventDispatcher->createSendEvent($this, $message)

    or

    $evt != $this->_eventDispatcher->createSendEvent($this, $message)

  • Milan Vasic

    Milan Vasic June 1st, 2011 @ 03:55 AM

    @Chris Corbyn what if we use it directly from php code? and not use sendmail, postfix or any other sender tool...what to do then?

  • Milan Vasic

    Milan Vasic June 18th, 2011 @ 02:27 AM

    We tried something like this

                $params = '-t -i';
                $transport = Swift_MailTransport::newInstance($params);
    

    And again we get problem with double dot.

  • Stefano Sala

    Stefano Sala March 7th, 2012 @ 02:21 AM

    Same happens to me with Symfony2 and Swift Mailer v4.1.5
    Anyone know a workaround for this issue?

  • Tim Drijvers

    Tim Drijvers May 7th, 2012 @ 07:38 PM

    We're currently having the same problem with the latest with 4.1.6 (also sendmail). Adding the params like Milan suggested didn't work.

  • Milan Vasic

    Milan Vasic May 9th, 2012 @ 06:06 AM

    @Tim yea strange problem, did you try to use any other encoding? maybe it helps...but most key players suggest to use QP. would be nice if we could somehow sort this out

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Comprehensive mailing tools for PHP 5.

Shared Ticket Bins

Attachments

Referenced by