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