Package javax.mail

Examples of javax.mail.Session


  /** */
  private void sendMessage(int port, String from, String subject, String body, String to) throws MessagingException, IOException
  {
    Properties mailProps = this.getMailProperties(SMTP_PORT);
    Session session = Session.getInstance(mailProps, null);
    //session.setDebug(true);

    MimeMessage msg = this.createMessage(session, from, to, subject, body);
    Transport.send(msg);
  }
View Full Code Here


  /** */
  private void sendMessageWithCharset(int port, String from, String subject, String body, String to, String charset)
    throws MessagingException
  {
    Properties mailProps = this.getMailProperties(port);
    Session session = Session.getInstance(mailProps, null);
    // session.setDebug(true);

    MimeMessage msg = this.createMessageWithCharset(session, from, to, subject, body, charset);
    Transport.send(msg);
  }
View Full Code Here

   * @throws RegainException If the preparation fails.
   */
  public void prepare(RawDocument rawDocument) throws RegainException {

    Properties mailProperties = System.getProperties();
    Session session = Session.getInstance(mailProperties, null);
    SharedByteArrayInputStream mimeInput = new SharedByteArrayInputStream(rawDocument.getContent());

    Collection<String> textParts = new ArrayList<String>();
    Collection<String> attachments = new ArrayList<String>();
    SimpleDateFormat simpleFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
View Full Code Here

        Properties properties = new Properties();
        properties.put("mail.user", JManageProperties.getAlertEmailFromName());
        properties.put("mail.host", JManageProperties.getEmailHost());
        properties.put("mail.from", JManageProperties.getAlertEmailFrom());
        properties.put("mail.transport.protocol", "smtp");
        Session session = Session.getInstance(properties);
        MimeMessage message = new MimeMessage(session);
        message.addRecipients(Message.RecipientType.TO, to);
        message.setSubject(subject);
        message.setText(content);
        Transport.send(message);
View Full Code Here

        if (!FACTORY_TYPE.equals(reference.getClassName())) {
            return null;
        }

        // Create and return a new Session object
        Session session = Session.getInstance(getSessionProperties(reference), getAuthenticator(reference));

        return session;
    }
View Full Code Here

      Map substitutions = ((JBossMonitorNotification) notification).substitutionMap();
      String message = Strings.subst(messageTemplate, substitutions, "%(", ")");
      String subject = Strings.subst(subjectTemplate, substitutions,  "%(", ")");
      try
      {
         Session session = (Session) new InitialContext().lookup("java:/Mail");
         // create a message
         //
         Address replyToList[] = { replyTo };
         Message newMessage = new MimeMessage(session);
         newMessage.setFrom(from);
         newMessage.setReplyTo(replyToList);
         newMessage.setRecipients(Message.RecipientType.TO, to);
         newMessage.setSubject(subject);
         newMessage.setSentDate(new java.util.Date());
         newMessage.setText(message);

         // Send newMessage
          //
          Transport transport = session.getTransport();
          transport.connect();
          transport.sendMessage(newMessage, to);
      }
      catch (Exception ex)
      {
View Full Code Here

   */
  public static void send(String sender, String recipients, String subject,
      String text) throws MessagingException {
    final Properties properties = Database.query(propertySupplier);
    if (properties != null) {
      Session session = Session.getInstance(properties,
          new javax.mail.Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
              return new PasswordAuthentication(properties
                  .getProperty("mail.smtp.user", ""),
                  properties.getProperty(
View Full Code Here

   }

   private void testMail(Context initCtx, Context myEnv) throws NamingException
   {
      // JavaMail Session
      Session session = (Session) myEnv.lookup("mail/DefaultMail");
      log.debug("mail/DefaultMail = " + session);
   }
View Full Code Here

   }

   private void testMail(Context initCtx, Context myEnv) throws NamingException
   {
      // JavaMail Session
      Session session = (Session) myEnv.lookup("mail/DefaultMail");
      log.debug("mail/DefaultMail = " + session);
   }
View Full Code Here

        if (m == null) {
            popSession.reply(session, "-ERR no such message");
        } else {
            popSession.reply(session, "+OK " + m.size() + " octets");
            Session mailSess = null;
            ChunkWriter store = new ChunkWriter() {

                public void newChunk(int i, byte[] data) {
                    IoBuffer bb = IoBuffer.wrap(data);
                    session.write(bb);
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.