-
Notifications
You must be signed in to change notification settings - Fork 184
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
Problems with unicode in sent message #460
Comments
Hi @StefanLiebig , you should use msg.content, as @file:DependsOn("com.icegreen:greenmail:1.6.9")
@file:DependsOn("org.jetbrains.kotlin:kotlin-test:1.7.0")
import com.icegreen.greenmail.util.GreenMail
import com.icegreen.greenmail.util.GreenMailUtil
import kotlin.script.experimental.dependencies.DependsOn
import kotlin.test.DefaultAsserter.assertEquals
val greenMail = GreenMail()
greenMail.start()
val content = "This is a test with ünicöde: \uD83C\uDF36"
val subject = "Some sübject"
GreenMailUtil.sendTextEmailTest(
"to@localhost", "from@localhost", subject,
content
)
val msg = greenMail.receivedMessages[0]
assertEquals("Checking subject",subject, msg.subject)
assertEquals("Checking content type", "text/plain; charset=UTF-8", msg.contentType)
assertEquals("Checking content", content, msg.content) // Fetch content
greenMail.stop() This should work, but there seems to be a bug with the content (strange eol?): java.lang.AssertionError: Checking content. Expected <This is a test with ünicöde: 🌶>, actual <This is a test with ünicöde: 🌶
>. |
Hi @marcelmay , Yes, the actual msg.content contains additional "\r\n". The tests "Testing your sending code (advanced)" do trim() the content! |
The trailing "\r\n" seems to be a bug in GreenMail SMTP. This now works for retrieving using IMAP and msg.content. Unfortunately, this fails for POP3, where JavaMail at the end of a message - CONTENT+'\r\n.\r\n' - only strips '.\r\n' - so there is always a CONTENT+'\r\n': It would be nice if JavaMail msg.content would behave transparent to IMAP or POP3 being used... |
Backport of #460: Fixes trailing \r\n for IMAP msg.getContent() SmtpConnection now strips the last \r\n before terminating dot of a received message. So for an IMAP plain text message, msg.getContent() equals to the sent plain text content, without being forced to trim off '\r\n' from the received content. Note that messages retrieved with POP3 still have trailing '\r\n'.
Using GreenMail 1.6.9
With the test code from https://greenmail-mail-test.github.io/greenmail/#examples (Testing your sending code (simple)) slightly modified with unicode character and umlaute (Kotlin):
The assertion fails.
Expected is: "This is a test with ünicöde: 🌶"
but is: "This is a test with =C3=BCnic=C3=B6de: =F0=9F=8C=B6"
Is this supposed to work?
The text was updated successfully, but these errors were encountered: