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
Comments
It would help me a lot if you have a sample email that exhibits this symptom. |
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:
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:
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:
At the end I send the my by using: 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:
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. |
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. |
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? |
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:
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:
|
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). |
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. |
Tested with JDK 11 just now, without problems. But that was Oracle, not OpenJDK. Can you try Oracle JDK 11? |
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. |
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:
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. |
Still, it might be worthwhile including this by default if missing... Might save some people like yourself a headache. |
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
The text was updated successfully, but these errors were encountered: