-2

I have to test a website with a registration function next week. After signing up the user has to receive an e-mail and I have to check

  • if the e-mail has been received
  • if the e-mail has a specific content (username, registration link).

I'll use Selenium. I had the idea to login at web.de or owa (Outlook) and check the e-mail there but is there any another more efficient way? Has somebody any experience and could recommend me a good link or solution?

Please note: the test has to run overnight and headless automatically during a Jenkins job. So I can't use a GUI based tool to check the SMTP server.

AcMuD
  • 131
  • 9
  • Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, [describe the problem](https://meta.stackoverflow.com/questions/254393/what-exactly-is-a-recommendation-question) and what has been done so far to solve it. – JeffC Jun 10 '18 at 14:54

1 Answers1

0

I'm using javax mail library which I consider as very useful.

Code example:

import javax.mail.*;

private void javaxMailExample() {

    // Set protocol.
    String protocol = "imaps";

    // Set properties.
    Properties props = new Properties();
    props.setProperty("mail.store.protocol", protocol);
    props.setProperty("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    props.setProperty("mail.imaps.socketFactory.fallback", "false");
    props.setProperty("mail.imaps.port", "993");
    props.setProperty("mail.imaps.socketFactory.port", "993");

    // Set outlook session.
    Session session = Session.getDefaultInstance(props, null);
    Store store = session.getStore(protocol);

    // Connect to session.
    store.connect("imap-mail.outlook.com", "email@domain.com", "password");

    // Read messages.
    Folder inbox = store.getFolder("INBOX");
    inbox.open(Folder.READ_WRITE);
    Message message = inbox.getMessages()[inbox.getMessages().length - 1];

See SMTP example.

AutomatedOwl
  • 1,039
  • 1
  • 8
  • 14