Example usage for org.apache.commons.mail Email MAIL_PORT

List of usage examples for org.apache.commons.mail Email MAIL_PORT

Introduction

In this page you can find the example usage for org.apache.commons.mail Email MAIL_PORT.

Prototype

String MAIL_PORT

To view the source code for org.apache.commons.mail Email MAIL_PORT.

Click Source Link

Usage

From source file:gov.nih.nci.firebird.service.messages.email.EmailServiceImplTest.java

@Before
public void setUp() throws AddressException {
    props = new Properties();
    props.setProperty(Email.MAIL_PORT, "25");
    session = Session.getInstance(props);
    mailbox = Mailbox.get(TEST_TO_ADDRESS);
    bean = new EmailServiceImpl();
    bean.setSenderName(TEST_FROM_NAME);/*from  w  w w .j a  v a2  s  .c  om*/
    bean.setSenderEmail(TEST_FROM_ADDRESS);
    bean.setMailSession(session);
    bean.setSendMail(true);
}

From source file:gov.nih.nci.firebird.service.messages.email.EmailServiceImpl.java

private void initEmailInfo(Email email) throws EmailException {
    email.setMailSession(mailSession);/*from   www .ja  v  a2 s. c  o m*/

    String smtpPort = email.getMailSession().getProperty(Email.MAIL_PORT);

    email.setFrom(senderEmail, senderName);
    if (StringUtils.isNumeric(smtpPort) && Integer.valueOf(smtpPort) > 0) {
        email.setSmtpPort(Integer.valueOf(smtpPort));
    }
}

From source file:gov.nih.nci.firebird.service.messages.email.EmailServiceImplTest.java

@Test
public void testSendMessageInvalidSessionPort() {
    props.setProperty(Email.MAIL_PORT, "-12345");
    bean.setMailSession(Session.getInstance(props));
    bean.sendMessage(TEST_TO_ADDRESS, null, null, testMessage);
    assertFalse(mailbox.isEmpty());/* w  ww. j a  v a 2  s  . co m*/
}

From source file:gov.nih.nci.firebird.service.messages.email.EmailServiceImplTest.java

@Test
public void testSendMessageInvalidSessionPortNonNumeric() {
    props.setProperty(Email.MAIL_PORT, "not a number");
    bean.setMailSession(Session.getInstance(props));
    bean.sendMessage(TEST_TO_ADDRESS, null, null, testMessage);
    assertFalse(mailbox.isEmpty());/*from  w w  w  . j  a v  a 2s  . co m*/
}