Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to send mails with calendar entry #313

Closed
jbreitung opened this issue Apr 29, 2021 · 11 comments
Closed

Failed to send mails with calendar entry #313

jbreitung opened this issue Apr 29, 2021 · 11 comments
Labels

Comments

@jbreitung
Copy link

Hi there,

I am experiencing issues when sending mails with a calendar entry attached. The stack trace i get is shown below. Mails without calendar attachments can be sent without any errors. Does anybody has an idea what might be the cause of this issue? I am using the newest 6.5.2 version of the dependency.

2021-04-29 10:14:32,922 ERROR [Simple Java Mail async mail sender, executor 1 / thread 20] de.xxx.xxx.xxx.Mailer : Failed to send mail with subject 'xxxxxxxxxxxxxxxxxx'!
org.simplejavamail.mailer.internal.MailerException: Third party error
at org.simplejavamail.mailer.internal.SendMailClosure.executeClosure(SendMailClosure.java:87)
at org.simplejavamail.mailer.internal.AbstractProxyServerSyncingClosure.run(AbstractProxyServerSyncingClosure.java:56)
at org.simplejavamail.internal.util.concurrent.AsyncOperationHelper$1.run(AsyncOperationHelper.java:75)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: javax.mail.MessagingException: IOException while sending message;
nested exception is:
javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/calendar; charset="UTF-8"; method="REQUEST"
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1350)
at org.simplejavamail.mailer.internal.util.TransportRunner$1.run(TransportRunner.java:52)
at org.simplejavamail.mailer.internal.util.TransportRunner.sendUsingConnectionPool(TransportRunner.java:86)
at org.simplejavamail.mailer.internal.util.TransportRunner.runOnSessionTransport(TransportRunner.java:72)
at org.simplejavamail.mailer.internal.util.TransportRunner.sendMessage(TransportRunner.java:48)
at org.simplejavamail.mailer.internal.SendMailClosure.executeClosure(SendMailClosure.java:78)
... 7 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/calendar; charset="UTF-8"; method="REQUEST"
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:885)
at javax.activation.DataHandler.writeTo(DataHandler.java:316)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:972)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:537)
at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:66)
at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:883)
at javax.activation.DataHandler.writeTo(DataHandler.java:316)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670)
at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1880)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)
... 12 more

@bbottema
Copy link
Owner

It would help me a lot if you have a sample email that exhibits this symptom.

@jbreitung
Copy link
Author

Hi, I have a lot of code which generates the email from our mail queue in the database. I tried to beak it down to how it works with a sample of input values:

As described in the documentation I first use the EmailPopulatingBuilder to build my Email with the following code:

EmailPopulatingBuilder emailBuilder = EmailBuilder.startingBlank()
                    .from("My Email Sender", "mailer@test.local")
                    .withReplyTo("My Email Sender", "mailer@test.local")
                    .to(recipients)
                    .withSubject("")
                    .withHTMLText("");

Email email = emailBuilder.buildEmail();
            
return email;

I used static values in this code snippet for the parameters of .from(...) and .withReplyTo(...) to keep it simple to read. The .to(...) method is called with an ArrayList containing only one receiver. The value of it should not matter. I found out, that different values for subject and HTML text will not affect the behavior of the error I get, so in this expample I kept it simple and left them just blank.

If an calendar entry should be attached to the mail, I am using the EmailBuilder to copy the mail with the calendar text to add:

if (StringUtils.isNotBlank(queuedMail.getiCalText())) {
      email = EmailBuilder.copying(email).withCalendarText(queuedMail.getiCalMethod(), queuedMail.getiCalText()).buildEmail();
}

The variable "queuedEmail" is an entity of my project which keeps all data of queued mails. As calendarMethod I use REQUEST and the textCalendar looks like the following:

BEGIN:VCALENDAR
PRODID:-//xxxxxxx GmbH//NONSMGL Project//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:REQUEST
BEGIN:VTIMEZONE
TZID:Europe/Brussels
LAST-MODIFIED:20201011T015911Z
TZURL:http://tzurl.org/zoneinfo/Europe/Brussels
X-LIC-LOCATION:Europe/Brussels
X-PROLEPTIC-TZNAME:LMT
BEGIN:STANDARD
TZNAME:BMT
TZOFFSETFROM:+001730
TZOFFSETTO:+001730
DTSTART:18800101T000000
END:STANDARD
BEGIN:STANDARD
TZNAME:WET
TZOFFSETFROM:+001730
TZOFFSETTO:+0000
DTSTART:18920501T001730
END:STANDARD
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
DTSTART:19141108T000000
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19160430T230000
RDATE:19400520T030000
RDATE:19430329T020000
RDATE:19440403T020000
RDATE:19450402T020000
RDATE:19460519T020000
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19161001T010000
RDATE:19421102T030000
RDATE:19431004T030000
RDATE:19440917T030000
RDATE:19450916T020000
RDATE:19461007T030000
RDATE:19770925T030000
RDATE:19781001T030000
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19170416T020000
RRULE:FREQ=YEARLY;UNTIL=19180415T010000Z;BYMONTH=4;BYDAY=3MO
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19170917T030000
RRULE:FREQ=YEARLY;UNTIL=19180916T010000Z;BYMONTH=9;BYDAY=3MO
END:STANDARD
BEGIN:STANDARD
TZNAME:WET
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
DTSTART:19181111T120000
RDATE:19191005T000000
RDATE:19201024T000000
RDATE:19211026T000000
RDATE:19391119T030000
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:WEST
TZOFFSETFROM:+0000
TZOFFSETTO:+0100
DTSTART:19190301T230000
RDATE:19200214T230000
RDATE:19210314T230000
RDATE:19220325T230000
RDATE:19230421T230000
RDATE:19240329T230000
RDATE:19250404T230000
RDATE:19260417T230000
RDATE:19270409T230000
RDATE:19280414T230000
RDATE:19290421T020000
RDATE:19300413T020000
RDATE:19310419T020000
RDATE:19320403T020000
RDATE:19330326T020000
RDATE:19340408T020000
RDATE:19350331T020000
RDATE:19360419T020000
RDATE:19370404T020000
RDATE:19380327T020000
RDATE:19390416T020000
RDATE:19400225T020000
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:WET
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
DTSTART:19221008T000000
RRULE:FREQ=YEARLY;UNTIL=19271001T230000Z;BYMONTH=10;BYMONTHDAY=2,3,4,5,6,7,8;BYDAY=SU
END:STANDARD
BEGIN:STANDARD
TZNAME:WET
TZOFFSETFROM:+0100
TZOFFSETTO:+0000
DTSTART:19281007T030000
RRULE:FREQ=YEARLY;UNTIL=19381002T020000Z;BYMONTH=10;BYMONTHDAY=2,3,4,5,6,7,8;BYDAY=SU
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0200
TZOFFSETTO:+0200
DTSTART:19440903T000000
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0100
TZOFFSETTO:+0100
DTSTART:19770101T000000
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19770403T020000
RRULE:FREQ=YEARLY;UNTIL=19800406T010000Z;BYMONTH=4;BYDAY=1SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19790930T030000
RRULE:FREQ=YEARLY;UNTIL=19950924T010000Z;BYMONTH=9;BYDAY=-1SU
END:STANDARD
BEGIN:DAYLIGHT
TZNAME:CEST
TZOFFSETFROM:+0100
TZOFFSETTO:+0200
DTSTART:19810329T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU
END:DAYLIGHT
BEGIN:STANDARD
TZNAME:CET
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
DTSTART:19961027T030000
RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20210430T052143Z
DTSTART:20210430T052100Z
DTEND:20210430T062100Z
SUMMARY:Mit iCal
UID:1619760101000-1001@xxx.xxxxx.de
TZID:Europe/Brussels
DESCRIPTION:\\n\\n\\nnull
SEQUENCE:0
TRANSP:OPAQUE
CLASS:PUBLIC
ORGANIZER;CN=Max Mustermann:MAILTO:null
ATTENDEE;ROLE=REQ-PARTICIPANT;CN=Erika Mustermann:mailto:erika.mustermann@xxx.xxx.com
BEGIN:VALARM
TRIGGER:-PT15M
ACTION:DISPLAY
DESCRIPTION:REMINDER
END:VALARM
END:VEVENT
END:VCALENDAR

At the end I send the my by using:
AsyncResponse response = this.mailer.sendMail(email, true);

I hope this may help you a little bit. I also broke down my maven dependency tree and searched for other mail dependencies which could cause a conflict with SimpleJavaMail, but only got this:

[INFO] +- org.simplejavamail:core-module:jar:6.4.5:compile
[INFO] |  +- com.sun.mail:jakarta.mail:jar:1.6.5:compile
[INFO] |  +- com.github.bbottema:emailaddress-rfc2822:jar:2.2.0:compile
[INFO] +- org.simplejavamail:simple-java-mail:jar:6.4.5:compile
[INFO] +- org.simplejavamail:batch-module:jar:6.4.5:compile
[INFO] |  \- org.simplejavamail:smtp-connection-pool:jar:1.1.1:compile

Does this issue might be caused by an unregistered DataContentHandler for the MIME type "text/calendar" in the Java Mail API? I will now try to downgrade to an older version of SimpleJavaMail and check if the error still persists.

@jbreitung
Copy link
Author

Okay, so I rolled back to version 6.0.3 which is the version I started with implementing SimpleJavaMail in my project:

I am not getting any stack trace anymore. So the issue might be caused by something that was changed after 6.0.3. Do you have any idea what could cause it? If not, I will try to figure out which release was the first version which caused the issue for me.

@bbottema
Copy link
Owner

Thank you for your work. However it would be much more effective if I had a sample email from you that triggers the error. Would that be possible?

@jbreitung
Copy link
Author

Hi, because I am not allowed to share production data of my project, I created a simple (ugly) code example which I executed to get the error:

final String CALENDAR_TEXT = "BEGIN:VCALENDAR\n"
                            + "PRODID:-//xxxxxxx GmbH//NONSMGL Project//EN\n"
                            + "VERSION:2.0\n"
                            + "CALSCALE:GREGORIAN\n"
                            + "METHOD:REQUEST\n"
                            + "BEGIN:VTIMEZONE\n"
                            + "TZID:Europe/Brussels\n"
                            + "LAST-MODIFIED:20201011T015911Z\n"
                            + "TZURL:http://tzurl.org/zoneinfo/Europe/Brussels\n"
                            + "X-LIC-LOCATION:Europe/Brussels\n"
                            + "X-PROLEPTIC-TZNAME:LMT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:BMT\n"
                            + "TZOFFSETFROM:+001730\n"
                            + "TZOFFSETTO:+001730\n"
                            + "DTSTART:18800101T000000\n"
                            + "END:STANDARD\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:WET\n"
                            + "TZOFFSETFROM:+001730\n"
                            + "TZOFFSETTO:+0000\n"
                            + "DTSTART:18920501T001730\n"
                            + "END:STANDARD\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:CET\n"
                            + "TZOFFSETFROM:+0000\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19141108T000000\n"
                            + "END:STANDARD\n"
                            + "BEGIN:DAYLIGHT\n"
                            + "TZNAME:CEST\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0200\n"
                            + "DTSTART:19160430T230000\n"
                            + "RDATE:19400520T030000\n"
                            + "RDATE:19430329T020000\n"
                            + "RDATE:19440403T020000\n"
                            + "RDATE:19450402T020000\n"
                            + "RDATE:19460519T020000\n"
                            + "END:DAYLIGHT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:CET\n"
                            + "TZOFFSETFROM:+0200\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19161001T010000\n"
                            + "RDATE:19421102T030000\n"
                            + "RDATE:19431004T030000\n"
                            + "RDATE:19440917T030000\n"
                            + "RDATE:19450916T020000\n"
                            + "RDATE:19461007T030000\n"
                            + "RDATE:19770925T030000\n"
                            + "RDATE:19781001T030000\n"
                            + "END:STANDARD\n"
                            + "BEGIN:DAYLIGHT\n"
                            + "TZNAME:CEST\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0200\n"
                            + "DTSTART:19170416T020000\n"
                            + "RRULE:FREQ=YEARLY;UNTIL=19180415T010000Z;BYMONTH=4;BYDAY=3MO\n"
                            + "END:DAYLIGHT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:CET\n"
                            + "TZOFFSETFROM:+0200\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19170917T030000\n"
                            + "RRULE:FREQ=YEARLY;UNTIL=19180916T010000Z;BYMONTH=9;BYDAY=3MO\n"
                            + "END:STANDARD\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:WET\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0000\n"
                            + "DTSTART:19181111T120000\n"
                            + "RDATE:19191005T000000\n"
                            + "RDATE:19201024T000000\n"
                            + "RDATE:19211026T000000\n"
                            + "RDATE:19391119T030000\n"
                            + "END:STANDARD\n"
                            + "BEGIN:DAYLIGHT\n"
                            + "TZNAME:WEST\n"
                            + "TZOFFSETFROM:+0000\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19190301T230000\n"
                            + "RDATE:19200214T230000\n"
                            + "RDATE:19210314T230000\n"
                            + "RDATE:19220325T230000\n"
                            + "RDATE:19230421T230000\n"
                            + "RDATE:19240329T230000\n"
                            + "RDATE:19250404T230000\n"
                            + "RDATE:19260417T230000\n"
                            + "RDATE:19270409T230000\n"
                            + "RDATE:19280414T230000\n"
                            + "RDATE:19290421T020000\n"
                            + "RDATE:19300413T020000\n"
                            + "RDATE:19310419T020000\n"
                            + "RDATE:19320403T020000\n"
                            + "RDATE:19330326T020000\n"
                            + "RDATE:19340408T020000\n"
                            + "RDATE:19350331T020000\n"
                            + "RDATE:19360419T020000\n"
                            + "RDATE:19370404T020000\n"
                            + "RDATE:19380327T020000\n"
                            + "RDATE:19390416T020000\n"
                            + "RDATE:19400225T020000\n"
                            + "END:DAYLIGHT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:WET\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0000\n"
                            + "DTSTART:19221008T000000\n"
                            + "RRULE:FREQ=YEARLY;UNTIL=19271001T230000Z;BYMONTH=10;BYMONTHDAY=2,3,4,5,6,7,8;BYDAY=SU\n"
                            + "END:STANDARD\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:WET\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0000\n"
                            + "DTSTART:19281007T030000\n"
                            + "RRULE:FREQ=YEARLY;UNTIL=19381002T020000Z;BYMONTH=10;BYMONTHDAY=2,3,4,5,6,7,8;BYDAY=SU\n"
                            + "END:STANDARD\n"
                            + "BEGIN:DAYLIGHT\n"
                            + "TZNAME:CEST\n"
                            + "TZOFFSETFROM:+0200\n"
                            + "TZOFFSETTO:+0200\n"
                            + "DTSTART:19440903T000000\n"
                            + "END:DAYLIGHT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:CET\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19770101T000000\n"
                            + "END:STANDARD\n"
                            + "BEGIN:DAYLIGHT\n"
                            + "TZNAME:CEST\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0200\n"
                            + "DTSTART:19770403T020000\n"
                            + "RRULE:FREQ=YEARLY;UNTIL=19800406T010000Z;BYMONTH=4;BYDAY=1SU\n"
                            + "END:DAYLIGHT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:CET\n"
                            + "TZOFFSETFROM:+0200\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19790930T030000\n"
                            + "RRULE:FREQ=YEARLY;UNTIL=19950924T010000Z;BYMONTH=9;BYDAY=-1SU\n"
                            + "END:STANDARD\n"
                            + "BEGIN:DAYLIGHT\n"
                            + "TZNAME:CEST\n"
                            + "TZOFFSETFROM:+0100\n"
                            + "TZOFFSETTO:+0200\n"
                            + "DTSTART:19810329T020000\n"
                            + "RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU\n"
                            + "END:DAYLIGHT\n"
                            + "BEGIN:STANDARD\n"
                            + "TZNAME:CET\n"
                            + "TZOFFSETFROM:+0200\n"
                            + "TZOFFSETTO:+0100\n"
                            + "DTSTART:19961027T030000\n"
                            + "RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU\n"
                            + "END:STANDARD\n"
                            + "END:VTIMEZONE\n"
                            + "BEGIN:VEVENT\n"
                            + "DTSTAMP:20210430T052143Z\n"
                            + "DTSTART:20210430T052100Z\n"
                            + "DTEND:20210430T062100Z\n"
                            + "SUMMARY:Mit iCal\n"
                            + "UID:1619760101000-1001@xxx.xxxxx.de\n"
                            + "TZID:Europe/Brussels\n"
                            + "DESCRIPTION:\\\\n\\\\n\\\\nnull\n"
                            + "SEQUENCE:0\n"
                            + "TRANSP:OPAQUE\n"
                            + "CLASS:PUBLIC\n"
                            + "ORGANIZER;CN=Max Mustermann:MAILTO:null\n"
                            + "ATTENDEE;ROLE=REQ-PARTICIPANT;CN=Erika Mustermann:mailto:erika.mustermann@xxx.xxx.com\n"
                            + "BEGIN:VALARM\n"
                            + "TRIGGER:-PT15M\n"
                            + "ACTION:DISPLAY\n"
                            + "DESCRIPTION:REMINDER\n"
                            + "END:VALARM\n"
                            + "END:VEVENT\n"
                            + "END:VCALENDAR";

                    EmailPopulatingBuilder emailBuilder = EmailBuilder.startingBlank()
                            .from("Max Mustermann", "jbreitung@xxx.com")
                            .withReplyTo("Max Mustermann", "jbreitung@xxx.com")
                            .to("Erika Mustermann", "jbreitung@xxx.com")
                            .withSubject("Make it break")
                            .withHTMLText("<img src='cid:wink1'><b>We should meet up!</b><img src='cid:wink2'>");

                    Email email = emailBuilder.buildEmail();

                    email = EmailBuilder.copying(email).withCalendarText(CalendarMethod.REQUEST, CALENDAR_TEXT).buildEmail();

                    final Email fMail = email;

                    try {
                        AsyncResponse response = this.mailer.sendMail(fMail, true);

                        //Response should not be null because we choose the async mailing
                        if (response != null) {
                            //If mail sent successfully just make an info log
                            response.onSuccess(() -> {
                                LOG.error("Successfully sent mail with subject '" + fMail.getSubject() + "'");
                            });

                            //If mail failed to send make an postbasket entry and error log
                            response.onException(e -> {
                                e.printStackTrace();
                                LOG.error("1Failed to send mail with subject '" + fMail.getSubject() + "': " + e.getMessage(), e);
                            });
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                        LOG.error("2Failed to send mail with subject '" + fMail.getSubject() + "': " + e.getMessage(), e);
                    }

The only specific here is that I use LOG as my Logger, but this should not matter. You might copy and paste this code to reproduce the issue. I used "this.mailer" as my configured mailer instance. The only thing you have to replace are the mail addresses I censored. The code above caused the following stack trace:

org.simplejavamail.mailer.internal.MailerException: Third party error
        at org.simplejavamail.mailer.internal.SendMailClosure.executeClosure(SendMailClosure.java:87)
        at org.simplejavamail.mailer.internal.AbstractProxyServerSyncingClosure.run(AbstractProxyServerSyncingClosure.java:56)
        at org.simplejavamail.internal.util.concurrent.AsyncOperationHelper$1.run(AsyncOperationHelper.java:75)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/calendar; charset="UTF-8"; method="REQUEST"
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1350)
        at org.simplejavamail.mailer.internal.util.TransportRunner$1.run(TransportRunner.java:52)
        at org.simplejavamail.mailer.internal.util.TransportRunner.sendUsingConnectionPool(TransportRunner.java:86)
        at org.simplejavamail.mailer.internal.util.TransportRunner.runOnSessionTransport(TransportRunner.java:72)
        at org.simplejavamail.mailer.internal.util.TransportRunner.sendMessage(TransportRunner.java:48)
        at org.simplejavamail.mailer.internal.SendMailClosure.executeClosure(SendMailClosure.java:78)
        ... 7 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/calendar; charset="UTF-8"; method="REQUEST"
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:885)
        at javax.activation.DataHandler.writeTo(DataHandler.java:316)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:972)
        at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:537)
        at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:66)
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:883)
        at javax.activation.DataHandler.writeTo(DataHandler.java:316)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670)
        at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1880)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)
        ... 12 more
2021-04-30 09:55:27,790 ERROR [Simple Java Mail async mail sender, executor 1 / thread 1]  de.xxx.xxx.Mailer : 1Failed to send mail with subject 'Make it break': Third party error
org.simplejavamail.mailer.internal.MailerException: Third party error
        at org.simplejavamail.mailer.internal.SendMailClosure.executeClosure(SendMailClosure.java:87)
        at org.simplejavamail.mailer.internal.AbstractProxyServerSyncingClosure.run(AbstractProxyServerSyncingClosure.java:56)
        at org.simplejavamail.internal.util.concurrent.AsyncOperationHelper$1.run(AsyncOperationHelper.java:75)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: javax.mail.MessagingException: IOException while sending message;
  nested exception is:
        javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/calendar; charset="UTF-8"; method="REQUEST"
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1350)
        at org.simplejavamail.mailer.internal.util.TransportRunner$1.run(TransportRunner.java:52)
        at org.simplejavamail.mailer.internal.util.TransportRunner.sendUsingConnectionPool(TransportRunner.java:86)
        at org.simplejavamail.mailer.internal.util.TransportRunner.runOnSessionTransport(TransportRunner.java:72)
        at org.simplejavamail.mailer.internal.util.TransportRunner.sendMessage(TransportRunner.java:48)
        at org.simplejavamail.mailer.internal.SendMailClosure.executeClosure(SendMailClosure.java:78)
        ... 7 more
Caused by: javax.activation.UnsupportedDataTypeException: no object DCH for MIME type text/calendar; charset="UTF-8"; method="REQUEST"
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:885)
        at javax.activation.DataHandler.writeTo(DataHandler.java:316)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:972)
        at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:537)
        at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:66)
        at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:883)
        at javax.activation.DataHandler.writeTo(DataHandler.java:316)
        at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1670)
        at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1880)
        at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1300)
        ... 12 more

@bbottema
Copy link
Owner

bbottema commented May 1, 2021

I'm not able to reproduce the bug, the mail sends just fine for me :/ I did this in a clean empty new project with only the core dependency (6.5.2).

Which JDK are you using? It's possible later JDK's removed some default mime types (considering packages like activation was removed altogether).

@bbottema bbottema removed the bug label May 1, 2021
@jbreitung
Copy link
Author

jbreitung commented May 1, 2021

Phew, I love these kinds of problems. I will try to find out more. But if you cannot reproduce it, other circumstances may seem to be causing it.

I am using openJDK 11.0.11 on Ubuntu Bionic. I will keep you up to date about what I find out.

@bbottema
Copy link
Owner

bbottema commented May 1, 2021

Tested with JDK 11 just now, without problems. But that was Oracle, not OpenJDK. Can you try Oracle JDK 11?

@jbreitung
Copy link
Author

Okay, I will try it with Oracle JDK when I am back at work next week. I will then share my result.

Thanks for your feedback so far.

@jbreitung
Copy link
Author

So, I tried a lot to get this problem solved in my environment. I've found that it only occurs when I start my project using JSVC. The problem does not occur when starting manually via java -jar. After many attempts to set the mailcaps in the source code, I finally came to a solution by adding the META-INF/mailcap file with the following content to my project:

text/plain;;            x-java-content-handler=com.sun.mail.handlers.text_plain
text/html;;             x-java-content-handler=com.sun.mail.handlers.text_html
text/xml;;              x-java-content-handler=com.sun.mail.handlers.text_xml
multipart/*;;           x-java-content-handler=com.sun.mail.handlers.multipart_mixed; x-java-fallback-entry=true
message/rfc822;;        x-java-content-handler=com.sun.mail.handlers.message_rfc822
text/calendar;;         x-java-content-handler=com.sun.mail.handlers.text_plain

This may not be the nicest solution, but in my case it makes SimpleJavaMail work as intended. There may be other users currently or later who have the same problem and can solve it with it. I suspect that there is a problem with the ClassLoader in my project and therefore the mailcaps set by SimpleJavaMail cannot be found. Many other developers have apparently already had this problem with Java Mail (not SimpleJavaMail), which is why I finally found this solution.

@bbottema
Copy link
Owner

bbottema commented May 3, 2021

Still, it might be worthwhile including this by default if missing... Might save some people like yourself a headache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants