View Javadoc

1   package com.ozacc.mail.mock;
2   
3   import java.io.UnsupportedEncodingException;
4   import java.util.ArrayList;
5   import java.util.List;
6   import java.util.Properties;
7   
8   import javax.mail.MessagingException;
9   import javax.mail.Session;
10  import javax.mail.internet.InternetAddress;
11  import javax.mail.internet.MimeMessage;
12  
13  import com.ozacc.mail.Mail;
14  import com.ozacc.mail.MailBuildException;
15  import com.ozacc.mail.MailException;
16  import com.ozacc.mail.SendMail;
17  import com.ozacc.mail.impl.MimeMessageBuilder;
18  
19  /***
20   * SendMailImpl¥¯¥é¥¹¤ÎMock¡£<br>
21   * ¼Â¸¤¹¤?SMTP¥µ¡¼¥Ð¤òÀßÄꤷ¤Æ¤â¡¢¼ÂºÝ¤Ë¤ÏÁ÷¿®¤µ¤?¤Þ¤»¤ó¡£
22   * ¥Ç¥Ð¥Ã¥°¥â¡¼¥É¤òÍ­¸ú¤Ë¤¹¤?¤È¡¢¥á¡¼¥?¤òÁ÷¿®¤¹¤?¥¿¥¤¥ß¥ó¥°¤Ç¥³¥ó¥½¡¼¥?¤ËÁ÷¿®¥á¡¼¥?ÆâÍÆ¤¬½ÐÎϤµ¤?¤Þ¤¹¡£
23   * <p>
24   * Mail¥¤¥ó¥¹¥¿¥ó¥¹¤? addExpectedMail() ¤Ë¥»¥Ã¥È¤· verify() ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤?¤È¡¢send() ¤µ¤?¤¿Mail¥¤¥ó¥¹¥¿¥ó¥¹¤ÈÁ´¤Æ¤Î¥×¥úÁѥƥ£(XHeader¤ò½?¤¯)¤¬°?Ãפ·¤Ê¤±¤?¤ÐAssertionFailedException¤¬¥¹¥ú½¼¤µ¤?¤Þ¤¹¡£
25   * <p>
26   * Î㤨¤Ð¡¢send() ¤µ¤?¤¿Mail¥¤¥ó¥¹¥¿¥ó¥¹¤ÎFrom¥¢¥É¥?¥¹¤È·?̾¤À¤±¥Á¥§¥Ã¥¯¤·¡¢¤½¤Î¾¤Î¥×¥úÁѥƥ£¤Ï¥Á¥§¥Ã¥¯¤·¤¿¤¯¤Ê¤¤¾?¹ç¤Ï¡¢MockMail¥¤¥ó¥¹¥¿¥ó¥¹¤ò»ÈÍѤ·¤Þ¤¹¡£
27   * <pre>Mail sentMail = new Mail();
28   *sentMail.setFrom("from@example.com");
29   *sentMail.setSubject("·?̾");
30   *sentMail.addTo("to@example.com");
31   *sentMail.setText("ưŪÀ¸À®¤µ¤?¤?ËÜʸ");
32   *
33   *Mail expectedMail = new Mail();
34   *expectedMail.setFrom("from@example.com");
35   *expectedMail.setSubject("·?̾");
36   *
37   *MockMail mockMail = new MockMail();
38   *mockMail.setFrom("from@example.com");
39   *mockMail.setSubject("·?̾");
40   *
41   *MockSendMail sendMail = new MockSendMail();
42   *sendMail.addExpectedMail(expectedMail);
43   *sendMail.send(sentMail);
44   *sendMail.verify(); // ¼ºÇÔ AssertionFailedException
45   *
46   *sendMail = new MockSendMail();
47   *sendMail.addExpectedMail(mockMail);
48   *sendMail.send(sentMail);
49   *sendMail.verify(); // À®¸?</pre>
50   * 
51   * @author Tomohiro Otsuka
52   * @version $Id: MockSendMail.java,v 1.6 2004/09/08 07:32:34 otsuka Exp $
53   */
54  public class MockSendMail implements SendMail {
55  
56  	/*** ¥Ç¥Õ¥©¥?¥È¤Î¥×¥úÁÈ¥³¥?¡£¡Ösmtp¡× */
57  	public static final String DEFAULT_PROTOCOL = "smtp";
58  
59  	/*** ¥Ç¥Õ¥©¥?¥È¤Î¥Ý¡¼¥È¡£¡Ö-1¡× */
60  	public static final int DEFAULT_PORT = -1;
61  
62  	/*** ¥Ç¥Õ¥©¥?¥È¤ÎSMTP¥µ¡¼¥Ð¡£¡Ölocalhost¡× */
63  	public static final String DEFAULT_HOST = "localhost";
64  
65  	/*** ISO-2022-JP */
66  	public static final String JIS_CHARSET = "ISO-2022-JP";
67  
68  	private static final String RETURN_PATH_KEY = "mail.smtp.from";
69  
70  	private String protocol = DEFAULT_PROTOCOL;
71  
72  	private String host = DEFAULT_HOST;
73  
74  	private int port = DEFAULT_PORT;
75  
76  	private String username;
77  
78  	private String password;
79  
80  	private String charset = JIS_CHARSET;
81  
82  	private String returnPath;
83  
84  	private List sentMails;
85  
86  	private List mimeMessages;
87  
88  	private List expectedMails;
89  
90  	private boolean debug;
91  
92  	/***
93  	 * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£
94  	 */
95  	public MockSendMail() {
96  		super();
97  		initialize();
98  	}
99  
100 	/***
101 	 * MockSendMail¥¤¥ó¥¹¥¿¥ó¥¹¤ò½é´?²½¤·¤Þ¤¹¡£
102 	 */
103 	public void initialize() {
104 		sentMails = new ArrayList();
105 		expectedMails = new ArrayList();
106 		mimeMessages = new ArrayList();
107 	}
108 
109 	/***
110 	 * Á÷¿®¤µ¤?¤¿¥á¡¼¥?¤ÎMimeMessage¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£
111 	 * Á÷¿®½ç¤ÎÇÛÎó¤Ç¤¹¡£
112 	 * 
113 	 * @return Á÷¿®¥á¡¼¥?¤ÎMimeMessage¥¤¥ó¥¹¥¿¥ó¥¹ÇÛÎ?
114 	 */
115 	public MimeMessage[] getMimeMessages() {
116 		return (MimeMessage[])mimeMessages.toArray(new MimeMessage[mimeMessages.size()]);
117 	}
118 
119 	/***
120 	 * Á÷¿®¤µ¤?¤¿Mail¥¤¥ó¥¹¥¿¥ó¥¹¤òÊÖ¤·¤Þ¤¹¡£Á÷¿®½ç¤ÎÇÛÎó¤Ç¤¹¡£
121 	 * 
122 	 * @return Á÷¿®¥á¡¼¥?¤ÎMail¥¤¥ó¥¹¥¿¥ó¥¹ÇÛÎ?
123 	 */
124 	public Mail[] getSentMails() {
125 		return (Mail[])sentMails.toArray(new Mail[sentMails.size()]);
126 	}
127 
128 	/***
129 	 * ¥Ç¥Ð¥Ã¥°¥â¡¼¥É¤¬Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤?¤«È½Äꤷ¤Þ¤¹¡£
130 	 * 
131 	 * @return Returns Í­¸ú¤Ë¤Ê¤Ã¤Æ¤¤¤?¾?¹? true
132 	 */
133 	public boolean isDebug() {
134 		return debug;
135 	}
136 
137 	/***
138 	 * ¥Ç¥Ð¥Ã¥°¥â¡¼¥É(¥³¥ó¥½¡¼¥?¤Ë¥úÁ°¤ò½ÐÎÏ)¤òÍ­¸ú¤Ë¤·¤Þ¤¹¡£
139 	 * ¥Ç¥Õ¥©¥?¥È¤Ï̵¸ú¤Ç¤¹¡£
140 	 * 
141 	 * @param debug ¥Ç¥Ð¥Ã¥°¥â¡¼¥É¤òÍ­¸ú¤Ë¤¹¤?¾?¹? true
142 	 */
143 	public void setDebug(boolean debug) {
144 		this.debug = debug;
145 	}
146 
147 	/***
148 	 * ¥Ç¥Ð¥Ã¥°¥â¡¼¥É¤¬Í­¸ú¤Î¤È¤­¡¢»ØÄꤵ¤?¤¿¥á¥Ã¥»¡¼¥¸¤ò¥³¥ó¥½¡¼¥?¤Ë½ÐÎϤ·¤Þ¤¹¡£
149 	 * 
150 	 * @param message ¥³¥ó¥½¡¼¥?½ÐÎϤ¹¤?¥á¥Ã¥»¡¼¥¸
151 	 */
152 	private void debug(String message) {
153 		if (debug) {
154 			System.out.println("[" + Thread.currentThread().getName() + "] DEBUG "
155 					+ getClass().getName() + " - " + message);
156 		}
157 	}
158 
159 	/***
160 	 * 
161 	 * @param expectedMail
162 	 */
163 	public void addExpectedMail(Mail expectedMail) {
164 		expectedMails.add(expectedMail);
165 	}
166 
167 	/***
168 	 * 
169 	 * @param expectedMails
170 	 */
171 	public void addExpectedMail(Mail[] expectedMails) {
172 		for (int i = 0; i < expectedMails.length; i++) {
173 			addExpectedMail(expectedMails[i]);
174 		}
175 	}
176 
177 	/***
178 	 * 
179 	 * @throws AssertionFailedException
180 	 */
181 	public void verify() throws AssertionFailedException {
182 		debug("======================================================");
183 		debug("                      verify()                        ");
184 		debug("======================================================");
185 
186 		// ¥á¡¼¥?¤Î¿ô¤òÈæ³Ó
187 		int numOfExpectedMails = expectedMails.size();
188 		int numOfSentMails = sentMails.size();
189 		if (numOfExpectedMails != numOfSentMails) {
190 			throw new AssertionFailedException("´?Âԥ᡼¥?¿?<" + numOfExpectedMails + ">¤ÈÁ÷¿®¥á¡¼¥?¿?<"
191 					+ numOfSentMails + ">¤¬°?Ãפ·¤Þ¤»¤ó¤Ç¤·¤¿¡£");
192 		}
193 
194 		debug("´?Âԥ᡼¥?¿ô¤ÈÁ÷¿®¥á¡¼¥?¿ô¤Ï°?Ãפ·¤Þ¤·¤¿¡£[" + numOfExpectedMails + "ÄÌ]");
195 
196 		// ¥á¡¼¥?ÆâÍÆ¤òÈæ³Ó
197 		for (int i = 0; i < numOfExpectedMails; i++) {
198 			Mail expected = (Mail)expectedMails.get(i);
199 			Mail sent = (Mail)sentMails.get(i);
200 			debug((i + 1) + "ÄÌÌܤΥÁ¥§¥Ã¥¯¤ò³«»Ï¤·¤Þ¤¹¡£("
201 					+ ((expected instanceof MockMail) ? "MockMail" : "Mail") + " - Mail)");
202 			checkEquality(expected, sent, i + 1);
203 			debug((i + 1) + "ÄÌÌܤδ?Âԥ᡼¥?¤ÈÁ÷¿®¥á¡¼¥?ÆâÍÆ¤Ï°?Ãפ·¤Þ¤·¤¿¡£");
204 		}
205 
206 		debug("verify¥×¥úÁ»¥¹¤ÏÁ´¤ÆÀ®¸ù¤·¤Þ¤·¤¿¡£");
207 		debug("======================================================");
208 	}
209 
210 	/***
211 	 * @param expected
212 	 * @param sent 
213 	 * @throws AssertionFailedException
214 	 */
215 	public static void checkEquality(Mail expected, Mail sent, int num)
216 																		throws AssertionFailedException {
217 		boolean mockMode = false;
218 		if (expected instanceof MockMail) {
219 			mockMode = true;
220 		}
221 
222 		// Return-Path
223 		if (!mockMode || (mockMode && expected.getReturnPath() != null)) {
224 			if (expected.getReturnPath() != null && sent.getReturnPath() != null) {
225 				if (!expected.getReturnPath().equals(sent.getReturnPath())) {
226 					throwExceptioWithMessage("Return-Path¥¢¥É¥?¥¹", expected.getReturnPath()
227 							.toUnicodeString(), sent.getReturnPath().toUnicodeString(), num);
228 				}
229 			} else if ((expected.getReturnPath() != null && sent.getReturnPath() == null)
230 					|| (expected.getReturnPath() == null && sent.getReturnPath() != null)) {
231 				throw new AssertionFailedException();
232 			}
233 		}
234 
235 		// to
236 		InternetAddress[] expectedAddresses = expected.getTo();
237 		InternetAddress[] sentAddresses = sent.getTo();
238 		if (!mockMode || (mockMode && expectedAddresses.length > 0)) {
239 			if (expectedAddresses.length != sentAddresses.length) {
240 				throwExceptioWithMessage("To¥¢¥É¥?¥¹¿?", Integer.toString(expectedAddresses.length),
241 						Integer.toString(sentAddresses.length), num);
242 			}
243 			for (int i = 0; i < expectedAddresses.length; i++) {
244 				if (!expectedAddresses[i].equals(sentAddresses[i])) {
245 					throwExceptioWithMessage("To¥¢¥É¥?¥¹", expectedAddresses[i].toUnicodeString(),
246 							sentAddresses[i].toUnicodeString(), num);
247 				}
248 			}
249 		}
250 
251 		// cc
252 		expectedAddresses = expected.getCc();
253 		sentAddresses = sent.getCc();
254 		if (!mockMode || (mockMode && expectedAddresses.length > 0)) {
255 			if (expectedAddresses.length != sentAddresses.length) {
256 				throwExceptioWithMessage("Cc¥¢¥É¥?¥¹¿?", Integer.toString(expectedAddresses.length),
257 						Integer.toString(sentAddresses.length), num);
258 			}
259 			for (int i = 0; i < expectedAddresses.length; i++) {
260 				if (!expectedAddresses[i].equals(sentAddresses[i])) {
261 					throwExceptioWithMessage("Cc¥¢¥É¥?¥¹", expectedAddresses[i].toUnicodeString(),
262 							sentAddresses[i].toUnicodeString(), num);
263 				}
264 			}
265 		}
266 
267 		// bcc
268 		expectedAddresses = expected.getBcc();
269 		sentAddresses = sent.getBcc();
270 		if (!mockMode || (mockMode && expectedAddresses.length > 0)) {
271 			if (expectedAddresses.length != sentAddresses.length) {
272 				throwExceptioWithMessage("Bcc¥¢¥É¥?¥¹¿?", Integer.toString(expectedAddresses.length),
273 						Integer.toString(sentAddresses.length), num);
274 			}
275 			for (int i = 0; i < expectedAddresses.length; i++) {
276 				if (!expectedAddresses[i].equals(sentAddresses[i])) {
277 					throwExceptioWithMessage("Bcc¥¢¥É¥?¥¹", expectedAddresses[i].toUnicodeString(),
278 							sentAddresses[i].toUnicodeString(), num);
279 				}
280 			}
281 		}
282 
283 		// Reply-To
284 		if (!mockMode || (mockMode && expected.getReplyTo() != null)) {
285 			if (expected.getReplyTo() != null && sent.getReplyTo() != null) {
286 				if (!expected.getReplyTo().equals(sent.getReplyTo())) {
287 					throwExceptioWithMessage("ReplyTo¥¢¥É¥?¥¹",
288 							expected.getReplyTo().toUnicodeString(), sent.getReplyTo()
289 									.toUnicodeString(), num);
290 				}
291 			} else if ((expected.getReplyTo() != null && sent.getReplyTo() == null)
292 					|| (expected.getReplyTo() == null && sent.getReplyTo() != null)) {
293 				throw new AssertionFailedException();
294 			}
295 		}
296 
297 		// ·?̾
298 		if (!mockMode || (mockMode && expected.getSubject().length() > 0)) {
299 			if (!expected.getSubject().equals(sent.getSubject())) {
300 				throwExceptioWithMessage("·?̾", expected.getSubject(), sent.getSubject(), num);
301 			}
302 		}
303 
304 		// ËÜʸ
305 		if (!mockMode || (mockMode && expected.getText().length() > 0)) {
306 			if (!expected.getText().equals(sent.getText())) {
307 				throwExceptioWithMessage("ËÜʸ", expected.getText(), sent.getText(), num);
308 			}
309 		}
310 
311 	}
312 
313 	/***
314 	 * °ú¿ô¤ÎÃͤò¼õ¤±¤Æ¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸¤òÀ¸À®¤·¡¢AssertionFailedError¤ò¥¹¥ú½¼¤·¤Þ¤¹¡£
315 	 * @param expectedValue
316 	 * @param sentValue
317 	 * @param num
318 	 * @throws AssertionFailedException 
319 	 */
320 	private static void throwExceptioWithMessage(String name, String expectedValue,
321 													String sentValue, int num)
322 																				throws AssertionFailedException {
323 		throw new AssertionFailedException(num + "ÈÖÌܤΥá¥Ã¥»¡¼¥¸¤Ç¡¢¡Ö" + name + "¡×¤¬°?Ãפ·¤Þ¤»¤ó¤Ç¤·¤¿¡£´?ÂÔÃÍ='"
324 				+ expectedValue + "', Á÷¿®ÃÍ='" + sentValue + "'");
325 	}
326 
327 	/***
328 	 * @see com.ozacc.mail.SendMail#send(com.ozacc.mail.Mail)
329 	 */
330 	public void send(Mail mail) throws MailException {
331 		send(new Mail[] { mail });
332 	}
333 
334 	/***
335 	 * @see com.ozacc.mail.SendMail#send(com.ozacc.mail.Mail[])
336 	 */
337 	public void send(Mail[] mails) throws MailException {
338 		debug("SMTP¥µ¡¼¥Ð[" + host + "]¤ËÀܳ¤¹¤?¥Õ¥ê¡£");
339 		debug("SMTP¥µ¡¼¥Ð[" + host + "]¤ËÀܳ¤·¤¿¥Õ¥ê¡£");
340 
341 		Session session = Session.getInstance(new Properties());
342 		for (int i = 0; i < mails.length; i++) {
343 
344 			Mail mail = mails[i];
345 
346 			// MimeMessage¤òÀ¸À®
347 			MimeMessage message = new MimeMessage(session);
348 			MimeMessageBuilder builder = new MimeMessageBuilder(message);
349 			try {
350 				builder.buildMimeMessage(mail);
351 			} catch (UnsupportedEncodingException e) {
352 				throw new MailBuildException("¥µ¥Ý¡¼¥È¤µ¤?¤Æ¤¤¤Ê¤¤Ê¸»ú¥³¡¼¥É¤¬»ØÄꤵ¤?¤Þ¤·¤¿¡£", e);
353 			} catch (MessagingException e) {
354 				throw new MailBuildException("MimeMessage¤ÎÀ¸À®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", e);
355 			}
356 			mimeMessages.add(message);
357 
358 			debug("¥á¡¼¥?¤òÁ÷¿®¤¹¤?¥Õ¥ê¡£");
359 			sentMails.add(mail);
360 			debug(mail.toString());
361 			debug("¥á¡¼¥?¤òÁ÷¿®¤·¤¿¥Õ¥ê¡£");
362 		}
363 
364 		debug("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤òÀÚÃǤ¹¤?¥Õ¥ê¡£");
365 		debug("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤òÀÚÃǤ·¤¿¥Õ¥ê¡£");
366 	}
367 
368 	/***
369 	 * @see com.ozacc.mail.SendMail#send(javax.mail.internet.MimeMessage)
370 	 */
371 	public void send(MimeMessage mimeMessage) throws MailException {
372 		throw new UnsupportedOperationException("¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¡£MockSendMail¤Ç¤Ï¡¢¤³¤Î¥á¥½¥Ã¥É¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£");
373 	}
374 
375 	/***
376 	 * @see com.ozacc.mail.SendMail#send(javax.mail.internet.MimeMessage[])
377 	 */
378 	public void send(MimeMessage[] mimeMessages) throws MailException {
379 		throw new UnsupportedOperationException("¿½¤·Ìõ¤´¤¶¤¤¤Þ¤»¤ó¡£MockSendMail¤Ç¤Ï¡¢¤³¤Î¥á¥½¥Ã¥É¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£");
380 	}
381 
382 	/***
383 	 * ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£
384 	 * 
385 	 * @return ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É
386 	 */
387 	public String getCharset() {
388 		return charset;
389 	}
390 
391 	/***
392 	 * ¥á¡¼¥?¤Î·?̾¤äËÜʸ¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É¤ò»ØÄꤷ¤Þ¤¹¡£
393 	 * ¥Ç¥Õ¥©¥?¥È¤Ï ISO-2022-JP ¤Ç¤¹¡£
394 	 * 
395 	 * @param charset ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É
396 	 */
397 	public void setCharset(String charset) {
398 		this.charset = charset;
399 	}
400 
401 	/***
402 	 * ¥»¥Ã¥È¤µ¤?¤¿SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹¤òÊÖ¤·¤Þ¤¹¡£
403 	 * 
404 	 * @return SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹
405 	 */
406 	public String getHost() {
407 		return host;
408 	}
409 
410 	/***
411 	 * SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£
412 	 * ¥Ç¥Õ¥©¥?¥È¤Ï localhost ¤Ç¤¹¡£
413 	 * 
414 	 * @param host SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹
415 	 */
416 	public void setHost(String host) {
417 		this.host = host;
418 	}
419 
420 	/***
421 	 * @return SMTP¥µ¡¼¥Ðǧ¾Ú¥Ñ¥¹¥?¡¼¥É
422 	 */
423 	public String getPassword() {
424 		return password;
425 	}
426 
427 	/***
428 	 * SMTP¥µ¡¼¥Ð¤ÎÀܳǧ¾Ú¤¬É¬Íפʾ?¹ç¤Ë¥Ñ¥¹¥?¡¼¥É¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£
429 	 * 
430 	 * @param password SMTP¥µ¡¼¥Ðǧ¾Ú¥Ñ¥¹¥?¡¼¥É
431 	 */
432 	public void setPassword(String password) {
433 		this.password = password;
434 	}
435 
436 	/***
437 	 * @return SMTP¥µ¡¼¥Ð¤Î¥Ý¡¼¥ÈÈÖ¹?
438 	 */
439 	public int getPort() {
440 		return port;
441 	}
442 
443 	/***
444 	 * SMTP¥µ¡¼¥Ð¤Î¥Ý¡¼¥ÈÈÖ¹æ¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£
445 	 * 
446 	 * @param port SMTP¥µ¡¼¥Ð¤Î¥Ý¡¼¥ÈÈÖ¹?
447 	 */
448 	public void setPort(int port) {
449 		this.port = port;
450 	}
451 
452 	/***
453 	 * @return Returns the protocol.
454 	 */
455 	public String getProtocol() {
456 		return protocol;
457 	}
458 
459 	/***
460 	 * @param protocol The protocol to set.
461 	 */
462 	public void setProtocol(String protocol) {
463 		this.protocol = protocol;
464 	}
465 
466 	/***
467 	 * @return Return-Path¥¢¥É¥?¥¹
468 	 */
469 	public String getReturnPath() {
470 		return returnPath;
471 	}
472 
473 	/***
474 	 * Return-Path¥¢¥É¥?¥¹¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£
475 	 * 
476 	 * @param returnPath Return-Path¥¢¥É¥?¥¹
477 	 */
478 	public void setReturnPath(String returnPath) {
479 		this.returnPath = returnPath;
480 	}
481 
482 	/***
483 	 * @return SMTP¥µ¡¼¥Ðǧ¾Ú¥æ¡¼¥¶Ì¾
484 	 */
485 	public String getUsername() {
486 		return username;
487 	}
488 
489 	/***
490 	 * SMTP¥µ¡¼¥Ð¤ÎÀܳǧ¾Ú¤¬É¬Íפʾ?¹ç¤Ë¥æ¡¼¥¶Ì¾¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£
491 	 * 
492 	 * @param username SMTP¥µ¡¼¥Ðǧ¾Ú¥æ¡¼¥¶Ì¾
493 	 */
494 	public void setUsername(String username) {
495 		this.username = username;
496 	}
497 
498 }