Ejemplo n.º 1
0
  public MailSender() {
    _host = ParseConstants.MAIL_HOST; // default smtp server
    _port = ParseConstants.MAIL_PORT; // default smtp port
    _sport = ParseConstants.MAIL_PORT; // default socketfactory port

    _user = ParseConstants.MAIL_USER; // username
    _pass = ParseConstants.MAIL_PASS; // password
    _from = ParseConstants.MAIL_USER; // email sent from
    _subject = ""; // email subject
    _body = ""; // email body

    _debuggable = false; // debug mode on or off - default off
    _auth = true; // smtp authentication - default on

    _multipart = new MimeMultipart();

    // There is something wrong with MailCap, javamail can not find a handler for the
    // multipart/mixed part, so this bit needs to be added.
    MailcapCommandMap mc = (MailcapCommandMap) CommandMap.getDefaultCommandMap();
    mc.addMailcap("text/html;; x-java-content-handler=com.sun.mail.handlers.text_html");
    mc.addMailcap("text/xml;; x-java-content-handler=com.sun.mail.handlers.text_xml");
    mc.addMailcap("text/plain;; x-java-content-handler=com.sun.mail.handlers.text_plain");
    mc.addMailcap("multipart/*;; x-java-content-handler=com.sun.mail.handlers.multipart_mixed");
    mc.addMailcap("message/rfc822;; x-java-content-handler=com.sun.mail.handlers.message_rfc822");
    CommandMap.setDefaultCommandMap(mc);
  }
Ejemplo n.º 2
0
  public static void initializeJavaActivationHandlers() {
    // DataHandler.writeTo() may search for DCH. So adding some default ones.
    try {
      CommandMap map = CommandMap.getDefaultCommandMap();
      if (map instanceof MailcapCommandMap) {
        MailcapCommandMap mailMap = (MailcapCommandMap) map;

        // registering our DCH since javamail's DCH doesn't handle
        if (!cmdMapInitialized(mailMap)) {
          mailMap.addMailcap(
              "text/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
          mailMap.addMailcap(
              "application/xml;;x-java-content-handler=com.sun.xml.internal.ws.encoding.XmlDataContentHandler");
          mailMap.addMailcap(
              "image/*;;x-java-content-handler=com.sun.xml.internal.ws.encoding.ImageDataContentHandler");
          mailMap.addMailcap(
              "text/plain;;x-java-content-handler=com.sun.xml.internal.ws.encoding.StringDataContentHandler");
        }
      }
    } catch (Throwable t) {
      // ignore the exception.
    }
  }