@Test @Disabled("Requires Gmail") void testGoogle_receiveUnseen() { ImapServer imapServer = MailServer.create() .host("imap.gmail.com") .port(993) .ssl(true) .auth("gmail_username", "gmail_password") .buildImapMailServer(); ReceiveMailSession session = imapServer.createSession(); session.open(); ReceivedEmail[] mails = session.receive() .filter(filter().flag(Flags.Flag.SEEN, false)) .unmark(Flags.Flag.SEEN) .fromFolder("INBOX") .get(); System.out.println(mails.length); Arrays.stream(mails).map(CommonEmail::subject).forEach(System.out::println); session.close(); } }
@Test void testSendEmailWithVariousAttachaments() { final SmtpServer smtpServer = MailServer.create() .host(HOST) .auth(USERNAME, PASSWORD) .ssl(true) .buildSmtpMailServer(); final SendMailSession session = smtpServer.createSession(); session.open(); final Email email = Email.create() .from("info@jodd.org") .to("igor.spasic@gmail.com") .subject("test-gmail") .textMessage("Hello!") .htmlMessage( "<html><META http-equiv=Content-Type content=\"text/html; charset=utf-8\">" + "<body><h1>Hey!</h1><img src='cid:jodd.png'>" + "<h2>Hay!</h2><img src='cid:jodd2.png'>" + "<h3></h3></body></html>") .embeddedAttachment(EmailAttachment.with().content(new File(PNG)).inline(false)) .embeddedAttachment(EmailAttachment.with().content(new File(PNG)).contentId("jodd2.png").inline(true)) .attachment(EmailAttachment.with().content(PNG)); session.sendMail(email); session.close(); } }
@Test void testImap604() { ImapServer imapServer = MailServer.create() .ssl(true) .host("secureimap.t-online.de") .port(993) .auth("user", "password") .buildImapMailServer(); assertNotNull(imapServer); } }