OSDN Git Service

2019-02-11
[hayashilib/hayashi.git] / src / jp / co / areaweb / tools / mail / SiteData.java
1 package jp.co.areaweb.tools.mail;\r
2 \r
3 import hayashi.yuu.tools.properties.Properties;\r
4 import java.io.FileInputStream;\r
5 \r
6 /**\r
7  * メールアカウント設定情報を保持するインスタンス\r
8  * @author hayashi\r
9  * @version     2010/02/05      項目'MAIL_SMTP_PORT'を追加\r
10  */\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
18     \r
19     /**\r
20      * 'POP before SMTP'認証を行うかどうか\r
21      */\r
22     public boolean POP_before_SMTP = false;\r
23     \r
24     /**\r
25      * 'USER_AUTH'認証を行うかどうか\r
26      */\r
27     public boolean USER_AUTH = false;\r
28     \r
29     /**\r
30      * POPサーバー名('POP before SMTP'認証時のみ)\r
31      */\r
32     public String MAIL_POP = "";\r
33     \r
34     /**\r
35      * POPアカウント('POP before SMTP'認証時のみ)\r
36      */\r
37     public String USER_ID = "";\r
38     \r
39     /**\r
40      * POPアカウントのパスワード('POP before SMTP'認証時のみ)\r
41      */\r
42     public String PASSWORD = "";\r
43 \r
44     /**\r
45      * 指定されたプロパティファイルに定義された値でインスタンスを生成する。\r
46      * @param propertyFile      設定値を定義したプロパティファイルのパス名\r
47      */\r
48     public SiteData(String propertyFile) {\r
49         try {\r
50             Properties properties = new Properties();\r
51             properties.setPasswordItem("PASSWORD");\r
52             properties.load(new FileInputStream(propertyFile));\r
53 \r
54             String str = "";\r
55             if ((str = properties.getProperty("MAIL_SMTP")) != null) {\r
56                 MAIL_SMTP = str;\r
57             }\r
58             if ((str = properties.getProperty("MAIL_SMTP_PORT")) != null) {\r
59                 MAIL_SMTP_PORT = str;\r
60             }\r
61             if ((str = properties.getProperty("MAIL_FROM")) != null) {\r
62                 MAIL_FROM = str;\r
63             }\r
64             if ((str = properties.getProperty("MAIL_FROM")) != null) {\r
65                 MAIL_FROM = str;\r
66             }\r
67             if ((str = properties.getProperty("MAIL_TO")) != null) {\r
68                 MAIL_TO = str;\r
69             }\r
70             if ((str = properties.getProperty("MAIL_CC")) != null) {\r
71                 MAIL_CC = str;\r
72             }\r
73             if ((str = properties.getProperty("MAIL_BCC")) != null) {\r
74                 MAIL_BCC = str;\r
75             }\r
76             \r
77             str = properties.getProperty("MAIL_POP_before_SMTP");\r
78             if ((str != null) && str.equals("true")) {\r
79                 POP_before_SMTP = true;\r
80             }\r
81             str = properties.getProperty("MAIL_SMTP_AUTH");\r
82             if ((str != null) && str.equals("true")) {\r
83                 USER_AUTH = true;\r
84             }\r
85             if ((str = properties.getProperty("MAIL_POP")) != null) {\r
86                 MAIL_POP = str;\r
87             }\r
88             if ((str = properties.getProperty("USER_ID")) != null) {\r
89                 USER_ID = str;\r
90             }\r
91             if ((str = properties.getProperty("PASSWORD")) != null) {\r
92                 PASSWORD = str;\r
93             }\r
94         }\r
95         catch(Exception e) {\r
96             System.out.println(e);\r
97         }\r
98     }\r
99 }\r