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 {
23 private String _username;
25 private String _password;
28 * Constructs the mail server.
31 * Host name of the SMTP server.
33 * Port name of the SMTP server.
35 * Username to use for authentication or null if no
36 * authentication is required.
38 * Password to use for authentication or null if no authenticatio
41 public MailServer(String aHost, int aPort, String aUsername,
45 _username = aUsername;
46 _password = aPassword;
54 * @throws EmailException
55 * In case of problems sending the mail.
57 public void send(Email aMail) throws EmailException {
58 Properties props = new Properties();
59 props.put("mail.transport.protocol", "smtp");
60 props.put("mail.smtp.host", _host);
61 props.put("mail.smtp.port", "" + _port);
63 Session mailSession = Session.getInstance(props,
64 new UsernamePasswordAuthenticator(_username, _password));
65 aMail.setMailSession(mailSession);