package foundation.send.mail; import java.util.Properties; import javax.mail.PasswordAuthentication; import org.dom4j.Element; import foundation.json.IJSONWriter; public class MailServer { private String name; private String debug; private String host; private String protocol; private String smtpAuth; private String port; private String account; private String password; private Properties propertys; public MailServer() { propertys = new Properties(); } public void load(Element element) { name = element.attributeValue("name"); debug = element.attributeValue("debug"); host = element.elementText("host"); protocol = element.elementText("protocol"); smtpAuth = element.elementText("auth"); port = element.elementText("port"); account = element.elementText("account"); password = element.elementText("password"); init(); } public void init() { propertys.clear(); propertys.setProperty("mail.debug", debug); propertys.setProperty("mail.host", host); propertys.setProperty("mail.transport.protocol", protocol); propertys.setProperty("mail.smtp.auth", smtpAuth); propertys.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); propertys.setProperty("mail.smtp.socketFactory.fallback", "false"); propertys.setProperty("mail.smtp.socketFactory.port", port); } public Properties getPropertys() { return propertys; } public Authenticator getAuthenticator() { return new Authenticator(); } public String getAccount() { return account; } public String getPassword() { return password; } public class Authenticator extends javax.mail.Authenticator { @Override protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(getAccount(), getPassword()); } } public String getName() { return name; } public void writeJSONBody(IJSONWriter writer) { // TODO Auto-generated method stub } }