Java Code Examples for com.icegreen.greenmail.user.GreenMailUser#deliver()
The following examples show how to use
com.icegreen.greenmail.user.GreenMailUser#deliver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EMailTestServer.java From syndesis with Apache License 2.0 | 6 votes |
public void deliverMultipartMessage(String user, String password, String from, String subject, String contentType, Object body) throws Exception { GreenMailUser greenUser = greenMail.setUser(user, password); MimeMultipart multiPart = new MimeMultipart(); MimeBodyPart textPart = new MimeBodyPart(); multiPart.addBodyPart(textPart); textPart.setContent(body, contentType); Session session = GreenMailUtil.getSession(server.getServerSetup()); MimeMessage mimeMessage = new MimeMessage(session); mimeMessage.setRecipients(Message.RecipientType.TO, greenUser.getEmail()); mimeMessage.setFrom(from); mimeMessage.setSubject(subject); mimeMessage.setContent(multiPart, "multipart/mixed"); greenUser.deliver(mimeMessage); }
Example 2
Source File: SmtpManager.java From greenmail with Apache License 2.0 | 6 votes |
private void handle(MovingMessage msg, MailAddress mailAddress) { try { GreenMailUser user = userManager.getUserByEmail(mailAddress.getEmail()); if (null == user) { String login = mailAddress.getEmail(); String email = mailAddress.getEmail(); String password = mailAddress.getEmail(); user = userManager.createUser(email, login, password); log.info("Created user login {} for address {} with password {} because it didn't exist before.", login, email, password); } user.deliver(msg); } catch (Exception e) { throw new IllegalStateException("Can not deliver message " + msg + " to " + mailAddress, e); } msg.releaseContent(); }
Example 3
Source File: ExampleReceiveNoRuleTest.java From greenmail with Apache License 2.0 | 6 votes |
@Test public void testReceive() throws MessagingException, IOException { //Start all email servers using non-default ports. GreenMail greenMail = new GreenMail(ServerSetupTest.SMTP_IMAP); try { greenMail.start(); //Use random content to avoid potential residual lingering problems final String subject = GreenMailUtil.random(); final String body = GreenMailUtil.random(); MimeMessage message = createMimeMessage(subject, body, greenMail); // Construct message GreenMailUser user = greenMail.setUser("[email protected]", "waelc", "soooosecret"); user.deliver(message); assertEquals(1, greenMail.getReceivedMessages().length); // --- Place your retrieve code here } finally { greenMail.stop(); } }
Example 4
Source File: TestConsumeEmail.java From localization_nifi with Apache License 2.0 | 5 votes |
public void addMessage(String testName, GreenMailUser user) throws MessagingException { Properties prop = new Properties(); Session session = Session.getDefaultInstance(prop); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("[email protected]")); message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]")); message.setSubject("Test email" + testName); message.setText("test test test chocolate"); user.deliver(message); }
Example 5
Source File: EMailTestServer.java From syndesis with Apache License 2.0 | 5 votes |
public void generateMail(String user, String password) { for (int i = 1; i <= 5; ++i) { // Use random content to avoid potential residual lingering problems String subject = GreenMailUtil.random(); String body = GreenMailUtil.random(); GreenMailUser greenUser = greenMail.setUser(user, password); MimeMessage message = createTextMessage(greenUser.getEmail(), "Ben" + i + "@test.com", subject, body); // Construct message greenUser.deliver(message); } assertEquals(5, greenMail.getReceivedMessages().length); }
Example 6
Source File: ExampleReceiveTest.java From greenmail with Apache License 2.0 | 5 votes |
@Test public void testReceive() throws MessagingException { GreenMailUser user = greenMail.setUser("[email protected]", "login-id", "password"); user.deliver(createMimeMessage()); // You can either create a more complex message... GreenMailUtil.sendTextEmailTest("[email protected]", "[email protected]", "subject", "body"); // ...or use the default messages assertEquals(2, greenMail.getReceivedMessages().length); // // --- Place your POP3 or IMAP retrieve code here }
Example 7
Source File: ITestConsumeEmail.java From nifi with Apache License 2.0 | 5 votes |
public void addMessage(String testName, GreenMailUser user) throws MessagingException { Properties prop = new Properties(); Session session = Session.getDefaultInstance(prop); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress("[email protected]")); message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]")); message.setSubject("Test email" + testName); message.setText("test test test chocolate"); user.deliver(message); }