| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| com.ozacc.mail.impl.SendMailProImpl |
|
|
| 1 | package com.ozacc.mail.impl; |
|
| 2 | ||
| 3 | import java.io.UnsupportedEncodingException; |
|
| 4 | import java.util.Date; |
|
| 5 | import java.util.Properties; |
|
| 6 | ||
| 7 | import javax.mail.Address; |
|
| 8 | import javax.mail.AuthenticationFailedException; |
|
| 9 | import javax.mail.MessagingException; |
|
| 10 | import javax.mail.Session; |
|
| 11 | import javax.mail.Transport; |
|
| 12 | import javax.mail.internet.MimeMessage; |
|
| 13 | ||
| 14 | import org.apache.commons.logging.Log; |
|
| 15 | import org.apache.commons.logging.LogFactory; |
|
| 16 | ||
| 17 | import com.ozacc.mail.Mail; |
|
| 18 | import com.ozacc.mail.MailAuthenticationException; |
|
| 19 | import com.ozacc.mail.MailBuildException; |
|
| 20 | import com.ozacc.mail.MailException; |
|
| 21 | import com.ozacc.mail.MailSendException; |
|
| 22 | import com.ozacc.mail.NotConnectedException; |
|
| 23 | import com.ozacc.mail.SendMailPro; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * SendMailPro¥¤¥ó¥¿¡¼¥Õ¥§¡¼¥¹¤Î¼ÂÁõ¥¯¥é¥¹¡£ |
|
| 27 | * |
|
| 28 | * @since 1.0 |
|
| 29 | * @author Tomohiro Otsuka |
|
| 30 | * @version $Id: SendMailProImpl.java,v 1.4.2.3 2005/01/29 23:09:36 otsuka Exp $ |
|
| 31 | */ |
|
| 32 | 1 | public class SendMailProImpl implements SendMailPro { |
| 33 | ||
| 34 | /** smtp */ |
|
| 35 | public static final String DEFAULT_PROTOCOL = "smtp"; |
|
| 36 | ||
| 37 | /** -1 */ |
|
| 38 | public static final int DEFAULT_PORT = -1; |
|
| 39 | ||
| 40 | /** localhost */ |
|
| 41 | public static final String DEFAULT_HOST = "localhost"; |
|
| 42 | ||
| 43 | /** ISO-2022-JP */ |
|
| 44 | public static final String JIS_CHARSET = "ISO-2022-JP"; |
|
| 45 | ||
| 46 | private static final String RETURN_PATH_KEY = "mail.smtp.from"; |
|
| 47 | ||
| 48 | 1 | private static Log log = LogFactory.getLog(SendMailProImpl.class); |
| 49 | ||
| 50 | /** Àܳ¥¿¥¤¥à¥¢¥¦¥È */ |
|
| 51 | private static final int DEFAULT_CONNECTION_TIMEOUT = 5000; |
|
| 52 | ||
| 53 | /** ÆÉ¹?¥¿¥¤¥à¥¢¥¦¥È */ |
|
| 54 | private static final int DEFAULT_READ_TIMEOUT = 5000; |
|
| 55 | ||
| 56 | 1 | private String protocol = DEFAULT_PROTOCOL; |
| 57 | ||
| 58 | 1 | private String host = DEFAULT_HOST; |
| 59 | ||
| 60 | 1 | private int port = DEFAULT_PORT; |
| 61 | ||
| 62 | private String username; |
|
| 63 | ||
| 64 | private String password; |
|
| 65 | ||
| 66 | 1 | private String charset = JIS_CHARSET; |
| 67 | ||
| 68 | private String returnPath; |
|
| 69 | ||
| 70 | private Session session; |
|
| 71 | ||
| 72 | private Transport transport; |
|
| 73 | ||
| 74 | private boolean connected; |
|
| 75 | ||
| 76 | private String messageId; |
|
| 77 | ||
| 78 | 1 | private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; |
| 79 | ||
| 80 | 1 | private int readTimeout = DEFAULT_READ_TIMEOUT; |
| 81 | ||
| 82 | /** |
|
| 83 | * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£ |
|
| 84 | */ |
|
| 85 | 2 | public SendMailProImpl() {} |
| 86 | ||
| 87 | /** |
|
| 88 | * ¥³¥ó¥¹¥È¥é¥¯¥¿¡£»ÈÍѤ¹¤?SMTP¥µ¡¼¥Ð¤ò»ØÄꤷ¤Þ¤¹¡£ |
|
| 89 | * |
|
| 90 | * @param host SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹ |
|
| 91 | */ |
|
| 92 | public SendMailProImpl(String host) { |
|
| 93 | 1 | this(); |
| 94 | 1 | setHost(host); |
| 95 | 1 | } |
| 96 | ||
| 97 | /** |
|
| 98 | * @see com.ozacc.mail.SendMailPro#connect() |
|
| 99 | */ |
|
| 100 | public synchronized void connect() throws MailException { |
|
| 101 | 0 | if (session == null) { |
| 102 | 0 | initSession(); |
| 103 | } |
|
| 104 | ||
| 105 | // ¥°¥ú½¼¥Ð¥?Return-Path¤ÎÀßÄ? |
|
| 106 | 0 | putOnReturnPath(this.returnPath); |
| 107 | ||
| 108 | try { |
|
| 109 | // SMTP¥µ¡¼¥Ð¤ËÀܳ |
|
| 110 | 0 | log.debug("SMTP¥µ¡¼¥Ð[" + host + "]¤ËÀܳ¤·¤Þ¤¹¡£"); |
| 111 | ||
| 112 | 0 | transport = session.getTransport(protocol); |
| 113 | 0 | transport.connect(host, port, username, password); |
| 114 | 0 | } catch (AuthenticationFailedException ex) { |
| 115 | 0 | log.error("SMTP¥µ¡¼¥Ð[" + host + "]¤Ø¤ÎÀܳǧ¾Ú¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 116 | 0 | throw new MailAuthenticationException(ex); |
| 117 | 0 | } catch (MessagingException ex) { |
| 118 | 0 | log.error("SMTP¥µ¡¼¥Ð[" + host + "]¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 119 | 0 | throw new MailSendException("SMTP¥µ¡¼¥Ð[" + host + "]¤Ø¤ÎÀܳ¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 120 | } |
|
| 121 | ||
| 122 | 0 | log.debug("SMTP¥µ¡¼¥Ð[" + host + "]¤ËÀܳ¤·¤Þ¤·¤¿¡£"); |
| 123 | ||
| 124 | 0 | connected = true; |
| 125 | 0 | } |
| 126 | ||
| 127 | /** |
|
| 128 | * Session¤Î½é´?²½¤ò¹Ô¤¤¤Þ¤¹¡£ |
|
| 129 | * ¥¿¥¤¥à¥¢¥¦¥ÈÃͤòÀßÄꤷ¤¿Properties¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 130 | */ |
|
| 131 | private void initSession() { |
|
| 132 | 0 | Properties prop = new Properties(); |
| 133 | // ¥¿¥¤¥à¥¢¥¦¥È¤ÎÀßÄ? |
|
| 134 | 0 | prop.put("mail.smtp.connectiontimeout", String.valueOf(connectionTimeout)); |
| 135 | 0 | prop.put("mail.smtp.timeout", String.valueOf(readTimeout)); |
| 136 | 0 | session = Session.getInstance(prop); |
| 137 | 0 | } |
| 138 | ||
| 139 | /** |
|
| 140 | * @see com.ozacc.mail.SendMailPro#disconnect() |
|
| 141 | */ |
|
| 142 | public synchronized void disconnect() throws MailException { |
|
| 143 | 0 | if (connected) { |
| 144 | try { |
|
| 145 | 0 | log.debug("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤òÀÚÃǤ·¤Þ¤¹¡£"); |
| 146 | ||
| 147 | // SMTP¥µ¡¼¥Ð¤È¤ÎÀܳ¤òÀÚÃÇ |
|
| 148 | 0 | transport.close(); |
| 149 | 0 | connected = false; |
| 150 | ||
| 151 | 0 | log.debug("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤òÀÚÃǤ·¤Þ¤·¤¿¡£"); |
| 152 | 0 | } catch (MessagingException ex) { |
| 153 | 0 | log.error("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳÀÚÃǤ˼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 154 | 0 | throw new MailException("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳÀÚÃǤ˼ºÇÔ¤·¤Þ¤·¤¿¡£"); |
| 155 | 0 | } finally { |
| 156 | // ¥°¥ú½¼¥Ð¥?Return-Path¤Î²ò½? |
|
| 157 | 0 | releaseReturnPath(false); |
| 158 | 0 | } |
| 159 | } else { |
|
| 160 | 0 | log.warn("SMTP¥µ¡¼¥Ð[" + host + "]¤È¤ÎÀܳ¤¬³ÎΩ¤µ¤?¤Æ¤¤¤Ê¤¤¾õÂ֤ǡ¢Àܳ¤ÎÀÚÃǤ¬¥?¥¯¥¨¥¹¥È¤µ¤?¤Þ¤·¤¿¡£"); |
| 161 | } |
|
| 162 | 0 | } |
| 163 | ||
| 164 | /** |
|
| 165 | * ReturnPath¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 166 | * |
|
| 167 | * @param returnPath |
|
| 168 | */ |
|
| 169 | private void putOnReturnPath(String returnPath) { |
|
| 170 | 0 | if (returnPath != null) { |
| 171 | 0 | session.getProperties().put(RETURN_PATH_KEY, returnPath); |
| 172 | 0 | log.debug("Return-Path[" + returnPath + "]¤òÀßÄꤷ¤Þ¤·¤¿¡£"); |
| 173 | } |
|
| 174 | 0 | } |
| 175 | ||
| 176 | /** |
|
| 177 | * ReturnPath¤ÎÀßÄê¤ò¥¯¥?¥¢¤·¤Þ¤¹¡£ |
|
| 178 | * <p> |
|
| 179 | * setGlobalReturnPathAgain¤¬true¤Ë»ØÄꤵ¤?¤Æ¤¤¤?¾?¹ç¡¢°?öReturn-PathÀßÄê¤ò¥¯¥?¥¢¤·¤¿¸å¤Ë¡¢ |
|
| 180 | * ¥°¥ú½¼¥Ð¥?¤ÊReturn-Path(setReturnPath()¥á¥½¥Ã¥É¤Ç¡¢¤³¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤Ë¥»¥Ã¥È¤µ¤?¤¿Return-Path¥¢¥É¥?¥¹)¤òÀßÄꤷ¤Þ¤¹¡£ |
|
| 181 | * ¥°¥ú½¼¥Ð¥?¤ÊReturn-Path¤¬¥»¥Ã¥È¤µ¤?¤Æ¤¤¤Ê¤±¤?¤ÐReturn-Path¤Ï¥¯¥?¥¢¤µ¤?¤¿¤Þ¤Þ¤Ë¤Ê¤ê¤Þ¤¹¡£ |
|
| 182 | * <p> |
|
| 183 | * ¥¯¥?¥¢¤µ¤?¤¿¾õÂÖ¤Çsend()¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤?¤?¤È¡¢From¤ÎÃͤ¬Return-Path¤Ë»ÈÍѤµ¤?¤Þ¤¹¡£ |
|
| 184 | * |
|
| 185 | * @param setGlobalReturnPathAgain Return-PathÀßÄê¤ò¥¯¥?¥¢¤·¤¿¸å¡¢ºÆÅÙ¥°¥ú½¼¥Ð¥?¤ÊReturn-Path¤ò¥»¥Ã¥È¤¹¤?¾?¹? true |
|
| 186 | */ |
|
| 187 | private void releaseReturnPath(boolean setGlobalReturnPathAgain) { |
|
| 188 | 0 | session.getProperties().remove(RETURN_PATH_KEY); |
| 189 | 0 | log.debug("Return-PathÀßÄê¤ò¥¯¥?¥¢¤·¤Þ¤·¤¿¡£"); |
| 190 | ||
| 191 | 0 | if (setGlobalReturnPathAgain && this.returnPath != null) { |
| 192 | 0 | putOnReturnPath(this.returnPath); |
| 193 | } |
|
| 194 | 0 | } |
| 195 | ||
| 196 | /** |
|
| 197 | * @see com.ozacc.mail.SendMailPro#send(javax.mail.internet.MimeMessage) |
|
| 198 | */ |
|
| 199 | public void send(MimeMessage mimeMessage) throws MailException { |
|
| 200 | Address[] addresses; |
|
| 201 | try { |
|
| 202 | 0 | addresses = mimeMessage.getAllRecipients(); |
| 203 | 0 | } catch (MessagingException ex) { |
| 204 | 0 | log.error("¥á¡¼¥?¤ÎÁ÷¿®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 205 | 0 | throw new MailSendException("¥á¡¼¥?¤ÎÁ÷¿®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 206 | } |
|
| 207 | 0 | processSend(mimeMessage, addresses); |
| 208 | 0 | } |
| 209 | ||
| 210 | /** |
|
| 211 | * @param mimeMessage |
|
| 212 | */ |
|
| 213 | private void processSend(MimeMessage mimeMessage, Address[] addresses) { |
|
| 214 | 0 | if (!connected) { |
| 215 | 0 | log.error("SMTP¥µ¡¼¥Ð¤Ø¤ÎÀܳ¤¬³ÎΩ¤µ¤?¤Æ¤¤¤Þ¤»¤ó¡£"); |
| 216 | 0 | throw new NotConnectedException("SMTP¥µ¡¼¥Ð¤Ø¤ÎÀܳ¤¬³ÎΩ¤µ¤?¤Æ¤¤¤Þ¤»¤ó¡£"); |
| 217 | } |
|
| 218 | ||
| 219 | try { |
|
| 220 | // Á÷¿®Æ?»?¤ò¥»¥Ã¥È |
|
| 221 | 0 | mimeMessage.setSentDate(new Date()); |
| 222 | 0 | mimeMessage.saveChanges(); |
| 223 | // Á÷¿® |
|
| 224 | 0 | log.debug("¥á¡¼¥?¤òÁ÷¿®¤·¤Þ¤¹¡£"); |
| 225 | 0 | transport.sendMessage(mimeMessage, addresses); |
| 226 | 0 | log.debug("¥á¡¼¥?¤òÁ÷¿®¤·¤Þ¤·¤¿¡£"); |
| 227 | 0 | } catch (MessagingException ex) { |
| 228 | 0 | log.error("¥á¡¼¥?¤ÎÁ÷¿®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 229 | 0 | throw new MailSendException("¥á¡¼¥?¤ÎÁ÷¿®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", ex); |
| 230 | } |
|
| 231 | 0 | } |
| 232 | ||
| 233 | /** |
|
| 234 | * @see com.ozacc.mail.SendMailPro#send(com.ozacc.mail.Mail) |
|
| 235 | */ |
|
| 236 | public void send(Mail mail) throws MailException { |
|
| 237 | 0 | if (mail.getReturnPath() != null) { |
| 238 | 0 | sendMailWithReturnPath(mail); |
| 239 | } else { |
|
| 240 | 0 | sendMail(mail); |
| 241 | } |
|
| 242 | 0 | } |
| 243 | ||
| 244 | /** |
|
| 245 | * »ØÄꤵ¤?¤¿Mail¤«¤éMimeMessage¤òÀ¸À®¤·¡¢send(MimeMessage)¥á¥½¥Ã¥É¤ËÅϤ·¤Þ¤¹¡£ |
|
| 246 | * |
|
| 247 | * @param mail |
|
| 248 | * @throws MailException |
|
| 249 | */ |
|
| 250 | private void sendMail(Mail mail) throws MailException { |
|
| 251 | // MimeMessage¤ÎÀ¸À® |
|
| 252 | 0 | MimeMessage message = createMimeMessage(); |
| 253 | 0 | MimeMessageBuilder builder = new MimeMessageBuilder(message, charset); |
| 254 | try { |
|
| 255 | 0 | builder.buildMimeMessage(mail); |
| 256 | 0 | } catch (UnsupportedEncodingException e) { |
| 257 | 0 | throw new MailBuildException("¥µ¥Ý¡¼¥È¤µ¤?¤Æ¤¤¤Ê¤¤Ê¸»ú¥³¡¼¥É¤¬»ØÄꤵ¤?¤Þ¤·¤¿¡£", e); |
| 258 | 0 | } catch (MessagingException e) { |
| 259 | 0 | throw new MailBuildException("MimeMessage¤ÎÀ¸À®¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", e); |
| 260 | } |
|
| 261 | // Á÷¿® |
|
| 262 | 0 | if (mail.getEnvelopeTo().length > 0) { |
| 263 | 0 | log.debug("¥á¡¼¥?¤Ïenvelope-to¥¢¥É¥?¥¹¤ËÁ÷¿®¤µ¤?¤Þ¤¹¡£"); |
| 264 | 0 | processSend(message, mail.getEnvelopeTo()); |
| 265 | } else { |
|
| 266 | 0 | send(message); |
| 267 | } |
|
| 268 | 0 | } |
| 269 | ||
| 270 | /** |
|
| 271 | * »ØÄꤵ¤?¤¿Mail¤Ë¥»¥Ã¥È¤µ¤?¤¿Return-Path¤òÀßÄꤷ¤Æ¡¢¥á¡¼¥?¤òÁ÷¿®¤·¤Þ¤¹¡£ |
|
| 272 | * Ʊ´?¥á¥½¥Ã¥É¤Ç¤¹¡£ |
|
| 273 | * |
|
| 274 | * @param mail |
|
| 275 | * @throws MailException |
|
| 276 | */ |
|
| 277 | private synchronized void sendMailWithReturnPath(Mail mail) throws MailException { |
|
| 278 | 0 | putOnReturnPath(mail.getReturnPath().getAddress()); |
| 279 | ||
| 280 | 0 | sendMail(mail); |
| 281 | ||
| 282 | 0 | releaseReturnPath(true); |
| 283 | 0 | } |
| 284 | ||
| 285 | /** |
|
| 286 | * ¿·¤·¤¤MimeMessage¥ª¥Ö¥¸¥§¥¯¥È¤òÀ¸À®¤·¤Þ¤¹¡£ |
|
| 287 | * |
|
| 288 | * @return ¿·¤·¤¤MimeMessage¥ª¥Ö¥¸¥§¥¯¥È |
|
| 289 | */ |
|
| 290 | public MimeMessage createMimeMessage() { |
|
| 291 | 0 | if (isMessageIdCustomized()) { |
| 292 | 0 | return new OMLMimeMessage(session, messageId); |
| 293 | } |
|
| 294 | 0 | return new MimeMessage(session); |
| 295 | } |
|
| 296 | ||
| 297 | /** |
|
| 298 | * Message-Id¥Ø¥Ã¥À¤Î¥É¥á¥¤¥óÉôʬ¤òÆÈ¼«¤Ë¥»¥Ã¥È¤·¤Æ¤¤¤?¤«¤É¤¦¤«È½Äꤷ¤Þ¤¹¡£ |
|
| 299 | * |
|
| 300 | * @return Message-Id¥Ø¥Ã¥À¤Î¥É¥á¥¤¥óÉôʬ¤òÆÈ¼«¤Ë¥»¥Ã¥È¤·¤Æ¤¤¤?¾?¹? true |
|
| 301 | */ |
|
| 302 | private boolean isMessageIdCustomized() { |
|
| 303 | 0 | return messageId != null; |
| 304 | } |
|
| 305 | ||
| 306 | /** |
|
| 307 | * @return Session¥¤¥ó¥¹¥¿¥ó¥¹ |
|
| 308 | */ |
|
| 309 | protected Session getSession() { |
|
| 310 | 0 | return session; |
| 311 | } |
|
| 312 | ||
| 313 | /** |
|
| 314 | * ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É¤òÊÖ¤·¤Þ¤¹¡£ |
|
| 315 | * |
|
| 316 | * @return ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É |
|
| 317 | */ |
|
| 318 | public String getCharset() { |
|
| 319 | 0 | return charset; |
| 320 | } |
|
| 321 | ||
| 322 | /** |
|
| 323 | * ¥á¡¼¥?¤Î·?̾¤äËÜʸ¤Î¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É¤ò»ØÄꤷ¤Þ¤¹¡£ |
|
| 324 | * ¥Ç¥Õ¥©¥?¥È¤Ï ISO-2022-JP ¤Ç¤¹¡£ |
|
| 325 | * <p> |
|
| 326 | * Æ?Ëܸ?´Ä¶¤ÇÍøÍѤ¹¤?¾?¹ç¤ÏÄ̾?Êѹ¹¤¹¤?ɬÍפϤ¢¤ê¤Þ¤»¤ó¡£ |
|
| 327 | * |
|
| 328 | * @param charset ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤Ë»ÈÍѤ¹¤?ʸ»ú¥³¡¼¥É |
|
| 329 | */ |
|
| 330 | public void setCharset(String charset) { |
|
| 331 | 0 | this.charset = charset; |
| 332 | 0 | } |
| 333 | ||
| 334 | /** |
|
| 335 | * @return Returns the host. |
|
| 336 | */ |
|
| 337 | public String getHost() { |
|
| 338 | 0 | return host; |
| 339 | } |
|
| 340 | ||
| 341 | /** |
|
| 342 | * SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 343 | * ¥Ç¥Õ¥©¥?¥È¤Ï localhost ¤Ç¤¹¡£ |
|
| 344 | * |
|
| 345 | * @param host SMTP¥µ¡¼¥Ð¤Î¥Û¥¹¥È̾¡¢¤Þ¤¿¤ÏIP¥¢¥É¥?¥¹ |
|
| 346 | */ |
|
| 347 | public void setHost(String host) { |
|
| 348 | 1 | this.host = host; |
| 349 | 1 | } |
| 350 | ||
| 351 | /** |
|
| 352 | * @return SMTP¥µ¡¼¥Ðǧ¾Ú¥Ñ¥¹¥?¡¼¥É |
|
| 353 | */ |
|
| 354 | public String getPassword() { |
|
| 355 | 0 | return password; |
| 356 | } |
|
| 357 | ||
| 358 | /** |
|
| 359 | * SMTP¥µ¡¼¥Ð¤ÎÀܳǧ¾Ú¤¬É¬Íפʾ?¹ç¤Ë¥Ñ¥¹¥?¡¼¥É¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 360 | * |
|
| 361 | * @param password SMTP¥µ¡¼¥Ðǧ¾Ú¥Ñ¥¹¥?¡¼¥É |
|
| 362 | */ |
|
| 363 | public void setPassword(String password) { |
|
| 364 | 0 | this.password = password; |
| 365 | 0 | } |
| 366 | ||
| 367 | /** |
|
| 368 | * @return SMTP¥µ¡¼¥Ð¤Î¥Ý¡¼¥ÈÈÖ¹? |
|
| 369 | */ |
|
| 370 | public int getPort() { |
|
| 371 | 0 | return port; |
| 372 | } |
|
| 373 | ||
| 374 | /** |
|
| 375 | * SMTP¥µ¡¼¥Ð¤Î¥Ý¡¼¥ÈÈÖ¹æ¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 376 | * |
|
| 377 | * @param port SMTP¥µ¡¼¥Ð¤Î¥Ý¡¼¥ÈÈÖ¹? |
|
| 378 | */ |
|
| 379 | public void setPort(int port) { |
|
| 380 | 0 | this.port = port; |
| 381 | 0 | } |
| 382 | ||
| 383 | /** |
|
| 384 | * ¥×¥úÁÈ¥³¥?¤òÊÖ¤·¤Þ¤¹¡£ |
|
| 385 | * |
|
| 386 | * @return ¥×¥úÁÈ¥³¥? |
|
| 387 | */ |
|
| 388 | public String getProtocol() { |
|
| 389 | 0 | return protocol; |
| 390 | } |
|
| 391 | ||
| 392 | /** |
|
| 393 | * ¥×¥úÁÈ¥³¥?¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£¥Ç¥Õ¥©¥?¥È¤Ï¡Ösmtp¡×¡£ |
|
| 394 | * |
|
| 395 | * @param protocol ¥×¥úÁÈ¥³¥? |
|
| 396 | */ |
|
| 397 | public void setProtocol(String protocol) { |
|
| 398 | 0 | this.protocol = protocol; |
| 399 | 0 | } |
| 400 | ||
| 401 | /** |
|
| 402 | * @return Return-Path¥¢¥É¥?¥¹ |
|
| 403 | */ |
|
| 404 | public String getReturnPath() { |
|
| 405 | 0 | return class="keyword">returnPath; |
| 406 | } |
|
| 407 | ||
| 408 | /** |
|
| 409 | * Return-Path¥¢¥É¥?¥¹¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 410 | * <p> |
|
| 411 | * Á÷¿®¤¹¤?Mail¥¤¥ó¥¹¥¿¥ó¥¹¤Ë»ØÄꤵ¤?¤¿From¥¢¥É¥?¥¹°Ê³°¤Î¥¢¥É¥?¥¹¤òReturn-Path¤È¤·¤¿¤¤¾?¹ç¤Ë»ÈÍѤ·¤Þ¤¹¡£ |
|
| 412 | * ¤³¤³¤Ç¥»¥Ã¥È¤µ¤?¤¿Return-Path¤è¤ê¡¢Mail¥¤¥ó¥¹¥¿¥ó¥¹¤Ë¥»¥Ã¥È¤µ¤?¤¿Return-Path¤¬Í¥À褵¤?¤Þ¤¹¡£ |
|
| 413 | * |
|
| 414 | * @param returnPath Return-Path¥¢¥É¥?¥¹ |
|
| 415 | */ |
|
| 416 | public void setReturnPath(String returnPath) { |
|
| 417 | 0 | this.returnPath = returnPath; |
| 418 | 0 | } |
| 419 | ||
| 420 | /** |
|
| 421 | * @return SMTP¥µ¡¼¥Ðǧ¾Ú¥æ¡¼¥¶Ì¾ |
|
| 422 | */ |
|
| 423 | public String getUsername() { |
|
| 424 | 0 | return username; |
| 425 | } |
|
| 426 | ||
| 427 | /** |
|
| 428 | * SMTP¥µ¡¼¥Ð¤ÎÀܳǧ¾Ú¤¬É¬Íפʾ?¹ç¤Ë¥æ¡¼¥¶Ì¾¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 429 | * |
|
| 430 | * @param username SMTP¥µ¡¼¥Ðǧ¾Ú¥æ¡¼¥¶Ì¾ |
|
| 431 | */ |
|
| 432 | public void setUsername(String username) { |
|
| 433 | 0 | this.username = username; |
| 434 | 0 | } |
| 435 | ||
| 436 | /** |
|
| 437 | * À¸À®¤µ¤?¤?MimeMessage¤ËÉÕ¤±¤é¤?¤?Message-Id¥Ø¥Ã¥À¤Î¥É¥á¥¤¥óÉôʬ¤ò»ØÄꤷ¤Þ¤¹¡£<br> |
|
| 438 | * »ØÄꤵ¤?¤Ê¤¤¾?¹?(null¤ä¶õʸ»úÎó¤Î¾?¹?)¤Ï¡¢JavaMail¤¬Message-Id¥Ø¥Ã¥À¤òÀ¸À®¤·¤Þ¤¹¡£ |
|
| 439 | * JavaMail¤¬À¸À®¤¹¤?¡ÖJavaMail.¼Â¹Ô¥æ¡¼¥¶Ì¾@¥Û¥¹¥È̾¡×¤ÎMessage-Id¤òÈò¤±¤¿¤¤¾?¹ç¤Ë¡¢¤³¤Î¥á¥½¥Ã¥É¤ò»ÈÍѤ·¤Þ¤¹¡£ |
|
| 440 | * <p> |
|
| 441 | * messageId¥×¥úÁѥƥ£¤¬¥»¥Ã¥È¤µ¤?¤Æ¤¤¤?¾?¹ç¡¢Mail¤«¤éÀ¸À®¤µ¤?¤?MimeMessage¤ÎMessage-Id¤Ë¤Ï |
|
| 442 | * <code>¥¿¥¤¥à¥¹¥¿¥ó¥× + ¥é¥ó¥À¥à¤ËÀ¸À®¤µ¤?¤?16·å¤Î¿ôÃÍ + ¤³¤³¤Ç¥»¥Ã¥È¤µ¤?¤¿ÃÍ</code> |
|
| 443 | * ¤¬»ÈÍѤµ¤?¤Þ¤¹¡£ |
|
| 444 | * <p> |
|
| 445 | * À¸À®¤µ¤?¤?Message-Id¤ÎÎã¡£ (¼ÂºÝ¤Î¿ôÃÍÉôʬ¤ÏÁ÷¿®¥á¡¼¥?Ëè¤ËÊѤ?¤ê¤Þ¤¹)<ul> |
|
| 446 | * <li>messageId¤Ë'example.com'¤ò»ØÄꤷ¤¿¾?¹ç¡¦¡¦¡¦1095714924963.5619528074501343@example.com</li> |
|
| 447 | * <li>messageId¤Ë'@example.com'¤ò»ØÄꤷ¤¿¾?¹ç¡¦¡¦¡¦1095714924963.5619528074501343@example.com (¾å¤ÈƱ¤¸)</li> |
|
| 448 | * <li>messageId¤Ë'OML@example.com'¤ò»ØÄꤷ¤¿¾?¹ç¡¦¡¦¡¦1095714924963.5619528074501343.OML@example.com</li> |
|
| 449 | * <li>messageId¤Ë'.OML@example.com'¤ò»ØÄꤷ¤¿¾?¹ç¡¦¡¦¡¦1095714924963.5619528074501343.OML@example.com (¾å¤ÈƱ¤¸)</li> |
|
| 450 | * </ul> |
|
| 451 | * <p> |
|
| 452 | * <strong>Ã?:</strong> ¤³¤ÎMessage-Id¤Ï<code>send(Mail)</code>¤«<code>send(Mail[])</code>¥á¥½¥Ã¥É¤¬¸Æ¤Ó¤À¤?¤¿»?¤Ë¤Î¤ß͸ú¤Ç¤¹¡£MimeMessage¤òľÀÜÁ÷¿®¤¹¤?¾?¹ç¤Ë¤ÏŬÍѤµ¤?¤Þ¤»¤ó¡£ |
|
| 453 | * |
|
| 454 | * @param messageId ¥á¡¼¥?¤ËÉÕ¤±¤é¤?¤?Message-Id¥Ø¥Ã¥À¤Î¥É¥á¥¤¥óÉôʬ |
|
| 455 | * @throws IllegalArgumentException @¤òÊ£¿ô´Þ¤ó¤Àʸ»úÎó¤ò»ØÄꤷ¤¿¾?¹? |
|
| 456 | */ |
|
| 457 | public void setMessageId(String messageId) { |
|
| 458 | 1 | if (messageId == null || messageId.length() < 1) { |
| 459 | 0 | return; |
| 460 | } |
|
| 461 | ||
| 462 | 1 | String[] parts = messageId.split("@"); |
| 463 | 1 | if (parts.length > 2) { |
| 464 | 0 | throw new IllegalArgumentException("messageId¥×¥úÁѥƥ£¤Ë'@'¤òÊ£¿ô´Þ¤à¤³¤È¤Ï¤Ç¤¤Þ¤»¤ó¡£[" + messageId |
| 465 | 0 | + "]"); |
| 466 | } |
|
| 467 | ||
| 468 | 1 | this.messageId = messageId; |
| 469 | 1 | } |
| 470 | ||
| 471 | /** |
|
| 472 | * SMTP¥µ¡¼¥Ð¤È¤ÎÀܳ¥¿¥¤¥à¥¢¥¦¥È¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 473 | * ñ°Ì¤Ï¥ß¥?Éᣥǥե©¥?¥È¤Ï5,000¥ß¥?ÉÃ(5ÉÃ)¤Ç¤¹¡£ |
|
| 474 | * <p> |
|
| 475 | * -1¤ò»ØÄꤹ¤?¤È̵¸ÂÂç¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢¤ªÁ¦¤á¤·¤Þ¤»¤ó¡£ |
|
| 476 | * |
|
| 477 | * @since 1.1.4 |
|
| 478 | * @param connectionTimeout SMTP¥µ¡¼¥Ð¤È¤ÎÀܳ¥¿¥¤¥à¥¢¥¦¥È |
|
| 479 | */ |
|
| 480 | public void setConnectionTimeout(int connectionTimeout) { |
|
| 481 | 0 | this.connectionTimeout = connectionTimeout; |
| 482 | 0 | } |
| 483 | ||
| 484 | /** |
|
| 485 | * SMTP¥µ¡¼¥Ð¤Ø¤ÎÁ÷¼õ¿®»?¤Î¥¿¥¤¥à¥¢¥¦¥È¤ò¥»¥Ã¥È¤·¤Þ¤¹¡£ |
|
| 486 | * ñ°Ì¤Ï¥ß¥?Éᣥǥե©¥?¥È¤Ï5,000¥ß¥?ÉÃ(5ÉÃ)¤Ç¤¹¡£ |
|
| 487 | * <p> |
|
| 488 | * -1¤ò»ØÄꤹ¤?¤È̵¸ÂÂç¤Ë¤Ê¤ê¤Þ¤¹¤¬¡¢¤ªÁ¦¤á¤·¤Þ¤»¤ó¡£ |
|
| 489 | * |
|
| 490 | * @since 1.1.4 |
|
| 491 | * @param readTimeout SMTP¥µ¡¼¥Ð¤Ø¤ÎÁ÷¼õ¿®»?¤Î¥¿¥¤¥à¥¢¥¦¥È |
|
| 492 | */ |
|
| 493 | public void setReadTimeout(int readTimeout) { |
|
| 494 | 0 | this.readTimeout = readTimeout; |
| 495 | 0 | } |
| 496 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |