Hello Cuba developers,
The application I am working on for a client is used to send regular newsletters to subscribers. However, the client is reporting that these sometimes arrive in the spam folder of subscribers.
We are still looking into the exact reason as to why that is. However, one possibility is that our email does not offer a plaintext body as an alternative to HTML. Through a service such as mail-tester.com this comes forward as the most likely culprit.
-1.105 MIME_HTML_ONLY Message only has text/html MIME parts
The client has asked me to ensure emails are provided with both a HTML and plaintext body. Sadly the ‘EmailService’ class provided for the Cuba platform does not appear to offer this functionality. Though I do see some protected functions that have something to do with MIME multipart
Using the function setBodyContentType() you are either forced to use “text/plain; charset=UTF-8” or “text/html; charset=UTF-8”.
I have tried to be obstinant and filled in “multipart/alternative” regardless, but to no avail. The email remains queued. Below is a stacktrace. Note that I have tried a few variations of multipart (with boundary, charset etc).
^[[33mweb_1_82bdfe5abd18 |^[[0m 14:49:24.438 WARN com.haulmont.cuba.core.app.Emailer - Unable to send email to 'test-2m50woe0d@srv1.mail-tester.com'
^[[33mweb_1_82bdfe5abd18 |^[[0m javax.mail.MessagingException: MIME part of type "multipart/mixed; boundary=test_boundary" contains object of type java.lang.String instead of MimeMultipart
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1475)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1125)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:515)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1471)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1125)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeMultipart.updateHeaders(MimeMultipart.java:515)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeBodyPart.updateHeaders(MimeBodyPart.java:1471)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeMessage.updateHeaders(MimeMessage.java:2190)
^[[33mweb_1_82bdfe5abd18 |^[[0m at javax.mail.internet.MimeMessage.saveChanges(MimeMessage.java:2151)
^[[33mweb_1_82bdfe5abd18 |^[[0m at com.haulmont.cuba.core.app.EmailSender.createMimeMessage(EmailSender.java:104)
^[[33mweb_1_82bdfe5abd18 |^[[0m at com.haulmont.cuba.core.app.EmailSender.sendEmail(EmailSender.java:65)
^[[33mweb_1_82bdfe5abd18 |^[[0m at com.haulmont.cuba.core.app.Emailer.sendSendingMessage(Emailer.java:181)
^[[33mweb_1_82bdfe5abd18 |^[[0m at com.haulmont.cuba.core.app.Emailer$EmailSendTask.run(Emailer.java:738)
^[[33mweb_1_82bdfe5abd18 |^[[0m at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
^[[33mweb_1_82bdfe5abd18 |^[[0m at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
^[[33mweb_1_82bdfe5abd18 |^[[0m at java.lang.Thread.run(Thread.java:748)
Has anybody tried anything like this before? Multipart body seems pretty standard for MIME. Or perhaps I am going about this problem in the wrong way?