Example usage for javax.mail Message reply

List of usage examples for javax.mail Message reply

Introduction

In this page you can find the example usage for javax.mail Message reply.

Prototype

public abstract Message reply(boolean replyToAll) throws MessagingException;

Source Link

Document

Get a new Message suitable for a reply to this message.

Usage

From source file:com.cubusmail.mail.MessageHandler.java

/**
 * @param msg/*from   www  . ja  va2  s .com*/
 * @throws MessagingException
 * @throws IOException
 */
public void createReplyMessage(Message msg, boolean replyAll) throws MessagingException, IOException {

    init();
    this.message = (MimeMessage) msg.reply(replyAll);
    Preferences prefs = SessionManager.get().getPreferences();
    MessageTextUtil.messageTextFromPart(msg, this, true, MessageTextMode.REPLY, prefs, 0);
    addReplyInfo(msg);
}

From source file:com.duroty.utils.mail.MessageUtilities.java

/**
 * Create a reply message to the given message. The reply message is
 * addressed to only the from / reply address or all receipients based on
 * the replyToAll flag./*from w  w  w. ja  v  a  2s .  c o  m*/
 *
 * @param fromName DOCUMENT ME!
 * @param fromEmail DOCUMENT ME!
 * @param message The message which to reply
 * @param body The attached text to include in the reply
 * @param replyToAll Reply to all receipients of the original message
 *
 * @return Message Reply message
 *
 * @exception MessagingException if the message contents are invalid
 */
public static Message createReply(Address[] from, Message message, boolean replyToAll)
        throws MessagingException {
    if ((from == null) || (from.length <= 0)) {
        throw new MessagingException("The from is null");
    }

    // create an empty reply message
    Message xreply = message.reply(replyToAll);

    // set the default from address
    xreply.setFrom(from[0]);

    // Message.reply() may set the "replied to" flag, so
    // attempt to save that new state and fail silently...
    try {
        message.saveChanges();
    } catch (MessagingException ex) {
    }

    return xreply;
}

From source file:com.clustercontrol.jobmanagement.util.SendApprovalMail.java

/**
 * ????//from   w  w w  .  j av a2 s.co  m
 * @param toAddressStr
 *            ?To
 * @param ccAddressStr
 *            ?Cc
 * @param subject
 *            ??
 * @param content
 *            
 * @throws MessagingException
 * @throws UnsupportedEncodingException
 */

public void sendMail(String[] toAddressStr, String[] ccAddressStr, String subject, String content)
        throws MessagingException, UnsupportedEncodingException {

    if (toAddressStr == null || toAddressStr.length <= 0) {
        // ??
        return;
    }
    /*
     *  https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html
     */
    Properties _properties = new Properties();
    _properties.setProperty("mail.debug",
            Boolean.toString(HinemosPropertyUtil.getHinemosPropertyBool("mail.debug", false)));
    _properties.setProperty("mail.store.protocol",
            HinemosPropertyUtil.getHinemosPropertyStr("mail.store.protocol", "pop3"));
    String protocol = HinemosPropertyUtil.getHinemosPropertyStr("mail.transport.protocol", "smtp");
    _properties.setProperty("mail.transport.protocol", protocol);
    _properties.put("mail.smtp.socketFactory", javax.net.SocketFactory.getDefault());
    _properties.put("mail.smtp.ssl.socketFactory", javax.net.ssl.SSLSocketFactory.getDefault());

    setProperties(_properties, "mail." + protocol + ".user", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".host", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".port", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".connectiontimeout",
            HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".timeout", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".writetimeout", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".from", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".localhost", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".localaddress", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".localport", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".ehlo", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.mechanisms",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".auth.login.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.plain.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.digest-md5.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.ntlm.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.ntlm.domain",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".auth.ntlm.flags",
            HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".submitter", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".dsn.notify", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".dsn.ret", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".allow8bitmime", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".sendpartial", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".sasl.enable", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".sasl.mechanisms",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".sasl.authorizationid",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".sasl.realm", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".sasl.usecanonicalhostname",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".quitwait", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".reportsuccess", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".socketFactory.class",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".socketFactory.fallback",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".socketFactory.port",
            HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".starttls.enable", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".starttls.required",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".socks.host", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".socks.port", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".mailextension", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".userset", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".noop.strict", HinemosPropertyTypeConstant.TYPE_TRUTH);

    setProperties(_properties, "mail.smtp.ssl.enable", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail.smtp.ssl.checkserveridentity", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail.smtp.ssl.trust", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail.smtp.ssl.socketFactory.class", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail.smtp.ssl.socketFactory.port", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail.smtp.ssl.protocols", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail.smtp.ssl.ciphersuites", HinemosPropertyTypeConstant.TYPE_STRING);

    /**
     * ?DB??
     */
    String _loginUser = HinemosPropertyUtil.getHinemosPropertyStr("mail.transport.user", "nobody");
    String _loginPassword = HinemosPropertyUtil.getHinemosPropertyStr("mail.transport.password", "password");
    String _fromAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.from.address", "admin@hinemos.com");
    String _fromPersonalName = HinemosPropertyUtil.getHinemosPropertyStr("mail.from.personal.name",
            "Hinemos Admin");
    _fromPersonalName = convertNativeToAscii(_fromPersonalName);

    String _replyToAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.reply.to.address",
            "admin@hinemos.com");
    String _replyToPersonalName = HinemosPropertyUtil.getHinemosPropertyStr("mail.reply.personal.name",
            "Hinemos Admin");
    _replyToPersonalName = convertNativeToAscii(_replyToPersonalName);

    String _errorsToAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.errors.to.address",
            "admin@hinemos.com");

    int _transportTries = HinemosPropertyUtil.getHinemosPropertyNum("mail.transport.tries", Long.valueOf(1))
            .intValue();
    int _transportTriesInterval = HinemosPropertyUtil
            .getHinemosPropertyNum("mail.transport.tries.interval", Long.valueOf(10000)).intValue();

    String _charsetAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.charset.address",
            _charsetAddressDefault);
    String _charsetSubject = HinemosPropertyUtil.getHinemosPropertyStr("mail.charset.subject",
            _charsetSubjectDefault);
    String _charsetContent = HinemosPropertyUtil.getHinemosPropertyStr("mail.charset.content",
            _charsetContentDefault);

    m_log.debug("initialized mail sender : from_address = " + _fromAddress + ", From = " + _fromPersonalName
            + " <" + _replyToAddress + ">" + ", Reply-To = " + _replyToPersonalName + " <" + _replyToAddress
            + ">" + ", Errors-To = " + _errorsToAddress + ", tries = " + _transportTries + ", tries-interval = "
            + _transportTriesInterval + ", Charset [address:subject:content] = [" + _charsetAddress + ":"
            + _charsetSubject + ":" + _charsetContent + "]");

    // JavaMail Session
    Session session = Session.getInstance(_properties);

    Message mineMsg = new MimeMessage(session);

    // ?????
    if (_fromAddress != null && _fromPersonalName != null) {
        mineMsg.setFrom(new InternetAddress(_fromAddress, _fromPersonalName, _charsetAddress));
    } else if (_fromAddress != null && _fromPersonalName == null) {
        mineMsg.setFrom(new InternetAddress(_fromAddress));
    }

    // REPLY-TO
    if (_replyToAddress != null && _replyToPersonalName != null) {
        InternetAddress reply[] = {
                new InternetAddress(_replyToAddress, _replyToPersonalName, _charsetAddress) };
        mineMsg.setReplyTo(reply);
        mineMsg.reply(true);
    } else if (_replyToAddress != null && _replyToPersonalName == null) {
        InternetAddress reply[] = { new InternetAddress(_replyToAddress) };
        mineMsg.setReplyTo(reply);
        mineMsg.reply(true);
    }

    // ERRORS-TO
    if (_errorsToAddress != null) {
        mineMsg.setHeader("Errors-To", _errorsToAddress);
    }

    // ?
    // TO
    InternetAddress[] toAddress = this.getAddress(toAddressStr);
    if (toAddress != null && toAddress.length > 0) {
        mineMsg.setRecipients(javax.mail.Message.RecipientType.TO, toAddress);
    } else {
        return; // TO?
    }

    // CC
    if (ccAddressStr != null) {
        InternetAddress[] ccAddress = this.getAddress(ccAddressStr);
        if (ccAddress != null && ccAddress.length > 0) {
            mineMsg.setRecipients(javax.mail.Message.RecipientType.CC, ccAddress);
        }
    }
    String message = "TO=" + Arrays.asList(toAddressStr);

    if (ccAddressStr != null) {
        message += ", CC=" + Arrays.asList(ccAddressStr);
    }
    m_log.debug(message);

    // ???
    mineMsg.setSubject(MimeUtility.encodeText(subject, _charsetSubject, "B"));

    // ?
    mineMsg.setContent(content, "text/plain; charset=" + _charsetContent);

    // ?
    mineMsg.setSentDate(HinemosTime.getDateInstance());

    // ???true??????
    for (int i = 0; i < _transportTries; i++) {
        Transport transport = null;
        try {
            // ?
            transport = session.getTransport();
            boolean flag = HinemosPropertyUtil.getHinemosPropertyBool("mail." + protocol + ".auth", false);
            if (flag) {
                transport.connect(_loginUser, _loginPassword);
            } else {
                transport.connect();
            }
            transport.sendMessage(mineMsg, mineMsg.getAllRecipients());
            break;
        } catch (AuthenticationFailedException e) {
            throw e;
        } catch (SMTPAddressFailedException e) {
            throw e;
        } catch (MessagingException me) {
            //_transportTries?sleep??? 
            if (i < (_transportTries - 1)) {
                m_log.info("sendMail() : retry sendmail. " + me.getMessage());
                try {
                    Thread.sleep(_transportTriesInterval);
                } catch (InterruptedException e) {
                }
                //_transportTries??INTERNAL????Exceptionthrow 
            } else {
                throw me;
            }
        } finally {
            if (transport != null) {
                transport.close();
            }
        }
    }
}

From source file:com.clustercontrol.notify.util.SendMail.java

public void sendMail(String[] toAddressStr, String[] ccAddressStr, String[] bccAddressStr, String subject,
        String content) throws MessagingException, UnsupportedEncodingException {

    if (toAddressStr == null || toAddressStr.length <= 0) {
        // ??//from w  ww  . j  a va  2s  .c o  m
        return;
    }

    /*
     *  https://javamail.java.net/nonav/docs/api/com/sun/mail/smtp/package-summary.html
     */
    Properties _properties = new Properties();
    _properties.setProperty("mail.debug",
            Boolean.toString(HinemosPropertyUtil.getHinemosPropertyBool("mail.debug", false)));
    _properties.setProperty("mail.store.protocol",
            HinemosPropertyUtil.getHinemosPropertyStr("mail.store.protocol", "pop3"));
    String protocol = HinemosPropertyUtil.getHinemosPropertyStr("mail.transport.protocol", "smtp");
    _properties.setProperty("mail.transport.protocol", protocol);
    _properties.put("mail.smtp.socketFactory", javax.net.SocketFactory.getDefault());
    _properties.put("mail.smtp.ssl.socketFactory", javax.net.ssl.SSLSocketFactory.getDefault());

    setProperties(_properties, "mail." + protocol + ".user", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".host", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".port", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".connectiontimeout",
            HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".timeout", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".writetimeout", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".from", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".localhost", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".localaddress", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".localport", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".ehlo", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.mechanisms",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".auth.login.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.plain.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.digest-md5.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.ntlm.disable",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".auth.ntlm.domain",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".auth.ntlm.flags",
            HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".submitter", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".dsn.notify", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".dsn.ret", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".allow8bitmime", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".sendpartial", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".sasl.enable", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".sasl.mechanisms",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".sasl.authorizationid",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".sasl.realm", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".sasl.usecanonicalhostname",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".quitwait", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".reportsuccess", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".socketFactory.class",
            HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".socketFactory.fallback",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".socketFactory.port",
            HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail." + protocol + ".starttls.enable", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".starttls.required",
            HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".socks.host", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".socks.port", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".mailextension", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail." + protocol + ".userset", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail." + protocol + ".noop.strict", HinemosPropertyTypeConstant.TYPE_TRUTH);

    setProperties(_properties, "mail.smtp.ssl.enable", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail.smtp.ssl.checkserveridentity", HinemosPropertyTypeConstant.TYPE_TRUTH);
    setProperties(_properties, "mail.smtp.ssl.trust", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail.smtp.ssl.socketFactory.class", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail.smtp.ssl.socketFactory.port", HinemosPropertyTypeConstant.TYPE_NUMERIC);
    setProperties(_properties, "mail.smtp.ssl.protocols", HinemosPropertyTypeConstant.TYPE_STRING);
    setProperties(_properties, "mail.smtp.ssl.ciphersuites", HinemosPropertyTypeConstant.TYPE_STRING);

    /**
     * ?DB??
     */
    String _loginUser = HinemosPropertyUtil.getHinemosPropertyStr("mail.transport.user", "nobody");
    String _loginPassword = HinemosPropertyUtil.getHinemosPropertyStr("mail.transport.password", "password");
    String _fromAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.from.address", "admin@hinemos.com");
    String _fromPersonalName = HinemosPropertyUtil.getHinemosPropertyStr("mail.from.personal.name",
            "Hinemos Admin");
    _fromPersonalName = convertNativeToAscii(_fromPersonalName);

    String _replyToAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.reply.to.address",
            "admin@hinemos.com");
    String _replyToPersonalName = HinemosPropertyUtil.getHinemosPropertyStr("mail.reply.personal.name",
            "Hinemos Admin");
    _replyToPersonalName = convertNativeToAscii(_replyToPersonalName);

    String _errorsToAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.errors.to.address",
            "admin@hinemos.com");

    int _transportTries = HinemosPropertyUtil.getHinemosPropertyNum("mail.transport.tries", Long.valueOf(1))
            .intValue();
    int _transportTriesInterval = HinemosPropertyUtil
            .getHinemosPropertyNum("mail.transport.tries.interval", Long.valueOf(10000)).intValue();

    String _charsetAddress = HinemosPropertyUtil.getHinemosPropertyStr("mail.charset.address",
            _charsetAddressDefault);
    String _charsetSubject = HinemosPropertyUtil.getHinemosPropertyStr("mail.charset.subject",
            _charsetSubjectDefault);
    String _charsetContent = HinemosPropertyUtil.getHinemosPropertyStr("mail.charset.content",
            _charsetContentDefault);

    m_log.debug("initialized mail sender : from_address = " + _fromAddress + ", From = " + _fromPersonalName
            + " <" + _replyToAddress + ">" + ", Reply-To = " + _replyToPersonalName + " <" + _replyToAddress
            + ">" + ", Errors-To = " + _errorsToAddress + ", tries = " + _transportTries + ", tries-interval = "
            + _transportTriesInterval + ", Charset [address:subject:content] = [" + _charsetAddress + ":"
            + _charsetSubject + ":" + _charsetContent + "]");

    // JavaMail Session
    Session session = Session.getInstance(_properties);

    Message mineMsg = new MimeMessage(session);

    // ?????
    if (_fromAddress != null && _fromPersonalName != null) {
        mineMsg.setFrom(new InternetAddress(_fromAddress, _fromPersonalName, _charsetAddress));
    } else if (_fromAddress != null && _fromPersonalName == null) {
        mineMsg.setFrom(new InternetAddress(_fromAddress));
    }
    // REPLY-TO
    if (_replyToAddress != null && _replyToPersonalName != null) {
        InternetAddress reply[] = {
                new InternetAddress(_replyToAddress, _replyToPersonalName, _charsetAddress) };
        mineMsg.setReplyTo(reply);
        mineMsg.reply(true);
    } else if (_replyToAddress != null && _replyToPersonalName == null) {
        InternetAddress reply[] = { new InternetAddress(_replyToAddress) };
        mineMsg.setReplyTo(reply);
        mineMsg.reply(true);
    }

    // ERRORS-TO
    if (_errorsToAddress != null) {
        mineMsg.setHeader("Errors-To", _errorsToAddress);
    }

    // ?
    // TO
    InternetAddress[] toAddress = this.getAddress(toAddressStr);
    if (toAddress != null && toAddress.length > 0) {
        mineMsg.setRecipients(javax.mail.Message.RecipientType.TO, toAddress);
    } else {
        return; // TO?
    }
    // CC
    if (ccAddressStr != null) {
        InternetAddress[] ccAddress = this.getAddress(ccAddressStr);
        if (ccAddress != null && ccAddress.length > 0) {
            mineMsg.setRecipients(javax.mail.Message.RecipientType.CC, ccAddress);
        }
    }
    // BCC
    if (bccAddressStr != null) {
        InternetAddress[] bccAddress = this.getAddress(bccAddressStr);
        if (bccAddress != null && bccAddress.length > 0) {
            mineMsg.setRecipients(javax.mail.Message.RecipientType.BCC, bccAddress);
        }
    }
    String message = "TO=" + Arrays.asList(toAddressStr);

    if (ccAddressStr != null) {
        message += ", CC=" + Arrays.asList(ccAddressStr);
    }
    if (bccAddressStr != null) {
        message += ", BCC=" + Arrays.asList(bccAddressStr);
    }
    m_log.debug(message);

    // ???
    mineMsg.setSubject(MimeUtility.encodeText(subject, _charsetSubject, "B"));

    // ?
    mineMsg.setContent(content, "text/plain; charset=" + _charsetContent);

    // ?
    mineMsg.setSentDate(HinemosTime.getDateInstance());

    // ???true??????
    for (int i = 0; i < _transportTries; i++) {
        Transport transport = null;
        try {
            // ?
            transport = session.getTransport();
            boolean flag = HinemosPropertyUtil.getHinemosPropertyBool("mail." + protocol + ".auth", false);
            if (flag) {
                transport.connect(_loginUser, _loginPassword);
            } else {
                transport.connect();
            }
            transport.sendMessage(mineMsg, mineMsg.getAllRecipients());
            break;
        } catch (AuthenticationFailedException e) {
            throw e;
        } catch (SMTPAddressFailedException e) {
            throw e;
        } catch (MessagingException me) {
            //_transportTries?sleep??? 
            if (i < (_transportTries - 1)) {
                m_log.info("sendMail() : retry sendmail. " + me.getMessage());
                try {
                    Thread.sleep(_transportTriesInterval);
                } catch (InterruptedException e) {
                }
                //_transportTries??INTERNAL????Exceptionthrow 
            } else {
                throw me;
            }
        } finally {
            if (transport != null) {
                transport.close();
            }
        }
    }
}