1 package hayashi.yuu.tools.mail;
\r
3 import hayashi.yuu.tools.properties.Properties;
\r
4 import java.io.FileInputStream;
\r
7 * メールアカウント設定情報を保持するインスタンス
\r
9 * @version 2010/02/05 項目'MAIL_SMTP_PORT'を追加
\r
11 public class SiteData {
\r
12 public String MAIL_SMTP = "192.168.0.10";
\r
13 public String MAIL_SMTP_PORT = "25";
\r
14 public String MAIL_FROM = "webserver@xxx.co.jp";
\r
15 public String MAIL_TO = "";
\r
16 public String MAIL_CC = "";
\r
17 public String MAIL_BCC = "";
\r
20 * 'POP before SMTP'認証を行うかどうか
\r
22 public boolean POP_before_SMTP = false;
\r
25 * 'USER_AUTH'認証を行うかどうか
\r
27 public boolean USER_AUTH = false;
\r
30 * 'STARTTLS'認証を行うかどうか
\r
32 public boolean STARTTLS = false;
\r
35 * POPサーバー名('POP before SMTP'認証時のみ)
\r
37 public String MAIL_POP = "";
\r
40 * POPアカウント('POP before SMTP'認証時のみ)
\r
42 public String USER_ID = "";
\r
45 * POPアカウントのパスワード('POP before SMTP'認証時のみ)
\r
47 public String PASSWORD = "";
\r
50 * 指定されたプロパティファイルに定義された値でインスタンスを生成する。
\r
51 * @param propertyFile 設定値を定義したプロパティファイルのパス名
\r
53 public SiteData(String propertyFile) {
\r
55 Properties properties = new Properties();
\r
56 properties.setPasswordItem("MAIL_PASSWORD");
\r
57 properties.load(new FileInputStream(propertyFile));
\r
60 catch(Exception e) {
\r
61 System.out.println(e);
\r
66 * 指定されたプロパティファイルに定義された値でインスタンスを生成する。
\r
67 * @param properties 設定値を定義したプロパティファイル
\r
69 public SiteData(Properties properties) {
\r
73 public void setup(java.util.Properties properties) {
\r
75 if ((str = properties.getProperty("mail.smtp.host")) != null) {
\r
78 if ((str = properties.getProperty("mail.smtp.port")) != null) {
\r
79 MAIL_SMTP_PORT = str;
\r
81 if ((str = properties.getProperty("mail.smtp.from")) != null) {
\r
84 if ((str = properties.getProperty("MAIL_TO")) != null) {
\r
87 if ((str = properties.getProperty("MAIL_CC")) != null) {
\r
90 if ((str = properties.getProperty("MAIL_BCC")) != null) {
\r
94 str = properties.getProperty("MAIL_POP_before_SMTP");
\r
95 if ((str != null) && str.equals("true")) {
\r
96 POP_before_SMTP = true;
\r
99 str = properties.getProperty("mail.smtp.auth");
\r
100 if ((str != null) && str.equals("true")) {
\r
104 str = properties.getProperty("mail.smtp.starttls.enable");
\r
105 if ((str != null) && str.equals("true")) {
\r
109 if ((str = properties.getProperty("MAIL_POP")) != null) {
\r
112 if ((str = properties.getProperty("mail.smtp.user")) != null) {
\r
115 if ((str = properties.getProperty("MAIL_PASSWORD")) != null) {
\r