2 * Copyright (c) 2005 UPS_SCS NL
5 package org.wamblee.crawler.kiss.notification;
7 import java.util.Properties;
9 import javax.mail.Session;
11 import org.apache.commons.mail.Email;
12 import org.apache.commons.mail.EmailException;
17 public class MailServer {
21 private String _username;
22 private String _password;
25 * Constructs the mail server interface.
26 * @param aHost Host name of the SMTP server.
27 * @param aPort Port name of the SMTP server.
28 * @param aUsername Username to use for authentication or null if no authentication is
30 * @param aPassword Password to use for authentication or null if no authenticatio is
33 public MailServer(String aHost, int aPort, String aUsername, String aPassword) {
36 _username = aUsername;
37 _password = aPassword;
42 * @param aMail Mail to send.
43 * @throws EmailException In case of problems sending the mail.
45 public void send(Email aMail) throws EmailException {
46 Properties props = new Properties();
47 props.put("mail.transport.protocol", "smtp");
48 props.put("mail.smtp.host", _host);
49 props.put("mail.smtp.port", "" + _port);
51 Session mailSession = Session.getInstance(props, new UsernamePasswordAuthenticator(_username, _password));
52 aMail.setMailSession(mailSession);