Search in sources :

Example 1 with GreenMailMimeMessage

use of com.icegreen.greenmail.test.util.GreenMailMimeMessage in project greenmail by greenmail-mail-test.

the class EscapingTest method testEscapeMessageID.

@Test
public void testEscapeMessageID() throws MessagingException {
    String to = "foo@localhost";
    String from = "bar`bar <bar@localhost>";
    String subject = "Bad IMAP Envelope";
    String body = "Example text";
    greenMail.setUser(to, to);
    Session smtpSession = greenMail.getSmtp().createSession();
    GreenMailMimeMessage mimeMessage = new GreenMailMimeMessage(smtpSession);
    mimeMessage.setRecipients(Message.RecipientType.TO, to);
    mimeMessage.setFrom(from);
    mimeMessage.setSubject(subject);
    mimeMessage.setText(body);
    GreenMailUtil.sendMimeMessage(mimeMessage);
    greenMail.waitForIncomingEmail(5000, 1);
    retrieveAndCheck(greenMail.getImap(), to, from, subject);
}
Also used : GreenMailMimeMessage(com.icegreen.greenmail.test.util.GreenMailMimeMessage) Session(jakarta.mail.Session) ServerSetupTest(com.icegreen.greenmail.util.ServerSetupTest) Test(org.junit.Test)

Aggregations

GreenMailMimeMessage (com.icegreen.greenmail.test.util.GreenMailMimeMessage)1 ServerSetupTest (com.icegreen.greenmail.util.ServerSetupTest)1 Session (jakarta.mail.Session)1 Test (org.junit.Test)1