user866364
user866364

Reputation:

JavaMail - Quoted printable remove . (dot) on new line

I'm using Java Mail to create emails, it's almost working but i'm facing a problem that i don'thave any idea how to resolve it.

The Content-Transfer-Encoding quoted-printable breaks my body in a lot of line with 77 characters each line and the problem happens when the next line starts and the first character is a . (dot).

An example of this:

  <table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" align=3D"center">
   <tbody>
    <tr>
     <td><br /><font color=3D"#666666" face=3D"Arial, Helvetica, sans-serif=
" size=3D"1">Lala n&atilde;o leleler lala lalalaa, <a href=3D"http://t.laiu=
com.ar/TestsTrackings/op.aspx?Osa8Br5zxNpqrv0AtVqBIiGIGG0CPNrUoxbqY7WYcGhP7=
LrlPvlBijtUAlN+b07u4cgghR7erUuf
P9PWGu7YtTkb51txcLYb9+6jzjBtWhf/L8Ai/gdZjrXfmIamviwsffMsjXa8mtnQm8n/XXkWuDw=
8
gW6EpcofAgSMsqpqmqxv85MRVG2vIFuD9v6lFD1H+dMk0RtR/cMhg/zgtjdIym6pig8sSTDT">c=
lalal lala</a>.</font><br /></td>
    </tr>
   </tbody>
  </table>

On line i have a link that starts with http://t.laiu.... and on next line it just removes my dot. When the user receive emails, he gots a link like t.laiucom.ar... instead t.laui.com.ar.

Anyone have an idea how can i avoid it?

Thank in advance.

Upvotes: 1

Views: 1445

Answers (1)

mata
mata

Reputation: 69012

In the comments you confirmed that you use Message.writeTo to create a file, and that the periods are there in that file.

So the problem is not javamail or the quoted printable encoding here.

The pickup service which picks up the file seems to already expect it to be fit for SMTP transport, as per rfc5321 (or rfc2821/rfc821), which means that periods at the beginning of a line must be doubled. Message.writeTo won't do that directly, because it does not care about the used transport, it just writes the message to a stream.

Usually, when sent to SMTP through javax.mail.Transport javamail handles this by wrapping the output stream in a SMTPOutputStream, so everything works fine. But by using Message.writeTo directly, you're operating on a lower level and need to deal with correctly formatting the output so it is accepted by the pickup service yourself.

That means you need to replace dots at the beginning of a line with two dots yourself. To do so you could use the SMTPOutputStream wrapper class mentioned above (but it's not public/documented API), or write your own stream wrapper which does the same. Or any other way to modify the generated data you like...

Upvotes: 1

Related Questions