Skip to content
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

Retriever using SMTPS TLS #243

Closed
javydreamercsw opened this issue Mar 29, 2018 · 1 comment
Closed

Retriever using SMTPS TLS #243

javydreamercsw opened this issue Mar 29, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@javydreamercsw
Copy link

Trying code as follows:

try (Retriever retriever = new Retriever(mailServer.getSmtps()))
    {
         Message[] messages = retriever.getMessages(email, password);
    if (messages != null)
    {
      for (Message m : messages)
      {
        TestCaseUtils.originalSystemOut.println("Subject: " + m.getSubject());
        TestCaseUtils.originalSystemOut.println("Sent Date: "
                + m.getSentDate());
        TestCaseUtils.originalSystemOut.println("From: "
                + Arrays.toString(m.getFrom()));
        TestCaseUtils.originalSystemOut.println("Subject: " + m.getContent());
      }
    }
    else
    {
      TestCaseUtils.originalSystemOut.println("No emails for: " + email);
    }
    }

Gives me an error on Message[] messages = retriever.getMessages(email, password); about invalid provider.

I create the server as suggested:

Security.setProperty("ssl.SocketFactory.provider",
            DummySSLSocketFactory.class.getName());
mailServer = new GreenMail(ServerSetupTest.SMTPS);
    mailServer.start();

Receiving the messages li below gives no issues:

Message[] messages = mailServer.getReceivedMessages();

@marcelmay
Copy link
Member

Retriever works by using the mail protocols (IMAP or POP3) for retrieving mails, and therefore works remotely.

A mailServer.getReceivedMessages() directly accesses the server instance (and won't work remotely).

Regarding your example:

  • Start GreenMail using SMTPS (for sending) and IMAPS for retrieving email:
    mailServer = new GreenMail(ServerSetupTest.SMTPS_IMAPS);
  • Use imap server when retrieving:
    try (Retriever retriever = new Retriever(mailServer.getImaps()))

@marcelmay marcelmay self-assigned this Apr 21, 2018
@marcelmay marcelmay added this to the 1.5.8 milestone Apr 21, 2018
@marcelmay marcelmay added the bug label Apr 21, 2018
marcelmay added a commit that referenced this issue Aug 26, 2018
Throw exception if server is not IMAP or POP3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants