Package javax.mail

Examples of javax.mail.Session


    }

    public Session getSession() {
        Properties props = new Properties();
        props.put("mail.smtp.auth", "true");
        Session session = Session.getInstance(props, null);
        return session;
    }
View Full Code Here


   }

   public Object getObjectInstance(Object obj, Name name, Context nameCtx,
         Hashtable<?, ?> environment) throws Exception
   {
      Session session = null;
      if(shareSessionInstance)
      {
         initSession();
         session = instance;
      }
View Full Code Here

    p.put("mail.smtp.host", mailhost);
    p.put("mail.smtp.timeout", mailhostTimeout);
    p.put("mail.smtp.connectiontimeout", mailhostTimeout);
    p.put("mail.smtp.ssl.enable", sslEnabled);
    p.put("mail.smtp.ssl.checkserveridentity", sslCheckCertificate);
    Session mailSession;
    if (smtpAuth == null) {
      mailSession = javax.mail.Session.getInstance(p);
    } else {
      // use smtp authentication from configuration
      p.put("mail.smtp.auth", "true");
      mailSession = Session.getDefaultInstance(p, smtpAuth);
    }
    if (Tracing.isDebugEnabled(MailHelper.class)) {
      // enable mail session debugging on console
      mailSession.setDebug(true);
    }
    return new MimeMessage(mailSession);
  }
View Full Code Here

  public static String sendEmail(final String htmlBody, final String subject,
      final String fromAddress, final String fromText,
      final String toAddress, final List<FileItem> files) {

    Properties props = new Properties();
        Session session = Session.getDefaultInstance(props, null);
        try {
          Multipart mp = new MimeMultipart();
          MimeBodyPart htmlPart = new MimeBodyPart();
            htmlPart.setContent(htmlBody, "text/html");
            htmlPart.setHeader("Content-type", "text/html; charset=UTF-8");
View Full Code Here

    private static Log log = LogFactory.getLog(IMAPSAuthenticator.class);

    @Override
    public void init(Storage store) {
        storage = store;
        final Session session =
                Session.getDefaultInstance(System.getProperties(), null);
        try {
            st = session.getStore("imaps");
        } catch (final NoSuchProviderException e) {
            log.error("Initialization for 'imaps' failed", e);
        }
    }
View Full Code Here

    private static Log log = LogFactory.getLog(POPSAuthenticator.class);

    @Override
    public void init(Storage store) {
        storage = store;
        final Session session =
                Session.getDefaultInstance(System.getProperties(), null);
        try {
            st = session.getStore("pop3s");
        } catch (final NoSuchProviderException e) {
            log.error("Initialization for 'pop3s' failed", e);
        }
    }
View Full Code Here

        if (conf.getConf_value().equals("1")){
          props.put("mail.smtp.starttls.enable","true");
        }
      }

      Session session = null;
      if (emailUsername != null && emailUsername.length() > 0
          && emailUserpass != null && emailUserpass.length() > 0) {
        //use SMTP Authentication
        props.put("mail.smtp.auth", "true");
        session = Session.getDefaultInstance(props,
View Full Code Here

        props.put("mail.smtp.starttls.enable","true");
      }
    }
   
    // Check for Authentification
    Session session = null;
    if (emailUsername != null && emailUsername.length() > 0
        && emailUserpass != null && emailUserpass.length() > 0) {
      //use SMTP Authentication
      props.put("mail.smtp.auth", "true");
      session = Session.getDefaultInstance(props,
View Full Code Here

     * connect to the email server
     * @return
     */
    private Store connectToMailService() {
        Properties property = System.getProperties();
        Session session = Session.getInstance(property, null);
        Store store = null;

        try {
            if(getServerType().equals(EmailDataType.SERVER_TYPE_POP3) && isUseSSL()){
                store = session.getStore("pop3s");
            }
            else if(getServerType().equals(EmailDataType.SERVER_TYPE_POP3) && !isUseSSL()){
                store = session.getStore("pop3");
            }
            else if(getServerType().equals(EmailDataType.SERVER_TYPE_IMAP) && !isUseSSL()){
                store = session.getStore("imap");
            }
            else if(getServerType().equals(EmailDataType.SERVER_TYPE_IMAP) && isUseSSL()){
                store = session.getStore("imaps");
            }
            else
                return null;
            store.connect(getServerURL(), getPort(), getUserName(), getUserPsw());

View Full Code Here

    }

    @Override
    public MimeMessage parseFile(File file, Report report) {
        InputStream is = null;
        Session s = null;
        MimeMessage message = null;
        try {
            is = new FileInputStream(file);
            s = Session.getDefaultInstance(System.getProperties(), null);
            message = new MimeMessage(s, is);
View Full Code Here

TOP

Related Classes of javax.mail.Session

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.