Commons Email
  1. Commons Email
  2. EMAIL-95

content duplicated with UTF8 encoding

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.3
    • Labels:
      None
    • Environment:

      linux

      Description

      I tooked original sample code and it worked fine. So I modified the text, set the encoding and ran it again - but the received email had each mime part twice.

      HtmlEmail email = new HtmlEmail();
      email.setHostName("smtp");
      email.addTo("leos.literak@aaa", "Leos");
      email.setFrom("leos.literak@aaa", "Me");
      email.setSubject("Test email with inline image");
      URL url = new URL("http://www.abclinuxu.cz/images/clanky/watzke/unixove-nastroje-logo.png");
      String cid = email.embed(url, "Apache logo");
      email.setCharset("UTF-8");
      email.setHtmlMsg("<html>žluťoučký kůň - <img src=\"cid:" + cid + "\"></html>");
      email.setTextMsg("žluťoučký kůň");

      Subject: Test email with inline image
      MIME-Version: 1.0
      Content-Type: multipart/mixed;
      boundary="----=_Part_0_17764792.1265348415830"

      ------=_Part_0_17764792.1265348415830
      Content-Type: multipart/related;
      boundary="----=_Part_3_12227392.1265348415896"

      ------=_Part_3_12227392.1265348415896
      Content-Type: multipart/alternative;
      boundary="----=_Part_4_18450577.1265348415896"

      ------=_Part_4_18450577.1265348415896
      Content-Type: text/plain; charset=UTF-8
      Content-Transfer-Encoding: base64

      xb5sdcWlb3XEjWvDvSBrxa/FiA==
      ------=_Part_4_18450577.1265348415896
      Content-Type: text/html; charset=UTF-8
      Content-Transfer-Encoding: quoted-printable

      <html>=C5=BElu=C5=A5ou=C4=8Dk=C3=BD k=C5=AF=C5=88 - <img src=3D"cid:wddstqa=
      bqx"></html>
      -----=_Part_4_18450577.1265348415896-

      ------=_Part_3_12227392.1265348415896
      Content-Type: image/png; name="Apache logo"
      Content-Transfer-Encoding: base64
      Content-Disposition: inline; filename="Apache logo"
      Content-ID: <wddstqabqx>

      iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz
      AAAG7AAABuwBHnU4NQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAe7SURB
      8csx12N60dP8NOIs8p6J+bS/hDjnMVyHWFVhAsgxj4I6fgsgJjch1pP2qVyhvxtMe1awQGUXwf/L
      0ain9RibfyUJgOMcYg75ZgtQ0l8EKhtc5pkF8NJCFPF/AbzM8B8Xxxza+PCJaQAAAABJRU5ErkJg
      gg==
      -----=_Part_3_12227392.1265348415896-

      ------=_Part_0_17764792.1265348415830
      Content-Type: multipart/related;
      boundary="----=_Part_1_16675983.1265348415831"

      ------=_Part_1_16675983.1265348415831
      Content-Type: multipart/alternative;
      boundary="----=_Part_2_26644003.1265348415831"

      ------=_Part_2_26644003.1265348415831
      Content-Type: text/plain; charset=UTF-8
      Content-Transfer-Encoding: base64

      xb5sdcWlb3XEjWvDvSBrxa/FiA==
      ------=_Part_2_26644003.1265348415831
      Content-Type: text/html; charset=UTF-8
      Content-Transfer-Encoding: quoted-printable

      <html>=C5=BElu=C5=A5ou=C4=8Dk=C3=BD k=C5=AF=C5=88 - <img src=3D"cid:wddstqa=
      bqx"></html>
      -----=_Part_2_26644003.1265348415831-

      ------=_Part_1_16675983.1265348415831
      Content-Type: image/png; name="Apache logo"
      Content-Transfer-Encoding: base64
      Content-Disposition: inline; filename="Apache logo"
      Content-ID: <wddstqabqx>

      iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz
      AAAG7AAABuwBHnU4NQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAe7SURB
      0ain9RibfyUJgOMcYg75ZgtQ0l8EKhtc5pkF8NJCFPF/AbzM8B8Xxxza+PCJaQAAAABJRU5ErkJg
      gg==
      -----=_Part_1_16675983.1265348415831-

      -----=_Part_0_17764792.1265348415830-

      This is a blocker for me. I would be gratefull, if you could fix it today, otherwise I will have to abandon this library and implement its functionality myself. Thanks in advance.

        Activity

        Hide
        Leos Literak added a comment -

        Hmm, my fault probably. I was planning to export MimeMessage and work with it, so I tried to run buildMessage:

        email.buildMimeMessage();
        MimeMessage message = email.getMimeMessage();
        // send the email
        String id = email.send();

        when I commented this line, email arrived correctly. Could you add some checks there to avoid this situation?

        Show
        Leos Literak added a comment - Hmm, my fault probably. I was planning to export MimeMessage and work with it, so I tried to run buildMessage: email.buildMimeMessage(); MimeMessage message = email.getMimeMessage(); // send the email String id = email.send(); when I commented this line, email arrived correctly. Could you add some checks there to avoid this situation?
        Hide
        Siegfried Goeschl added a comment -

        Yes, a good idea - I have a look

        Show
        Siegfried Goeschl added a comment - Yes, a good idea - I have a look
        Hide
        Siegfried Goeschl added a comment -

        Throwing an IllegalStateException when buildMimeMessage() is invoked more than once. Having said that I'm enforcing that an email can't be reused which could cause problems under rare circumstances.

        Show
        Siegfried Goeschl added a comment - Throwing an IllegalStateException when buildMimeMessage() is invoked more than once. Having said that I'm enforcing that an email can't be reused which could cause problems under rare circumstances.
        Hide
        Siegfried Goeschl added a comment -

        Reopening the issue because the correct state would be "resolved" and not "closed"

        Show
        Siegfried Goeschl added a comment - Reopening the issue because the correct state would be "resolved" and not "closed"
        Hide
        Siegfried Goeschl added a comment -

        Now it is in the state "resolved"

        Show
        Siegfried Goeschl added a comment - Now it is in the state "resolved"

          People

          • Assignee:
            Siegfried Goeschl
            Reporter:
            Leos Literak
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development