Example usage for javax.mail Authenticator getPasswordAuthentication

List of usage examples for javax.mail Authenticator getPasswordAuthentication

Introduction

In this page you can find the example usage for javax.mail Authenticator getPasswordAuthentication.

Prototype

protected PasswordAuthentication getPasswordAuthentication() 

Source Link

Document

Called when password authentication is needed.

Usage

From source file:org.webguitoolkit.messagebox.mail.MailChannel.java

private Session getSession() {
    Authenticator authenticator = new Authenticator();

    Properties sessionProps = new Properties();
    sessionProps.setProperty("mail.smtp.submitter", authenticator.getPasswordAuthentication().getUserName());
    sessionProps.setProperty("mail.smtp.auth", "true");
    sessionProps.put("mail.smtp.starttls.enable", "true");
    sessionProps.setProperty("mail.smtp.host", properties.getProperty("smtp.host"));
    sessionProps.setProperty("mail.smtp.port", properties.getProperty("smtp.port"));

    return Session.getInstance(sessionProps, authenticator);
}