Package javax.mail.internet

Examples of javax.mail.internet.MimeMessage


        chain.doEvent(event);
    }

    protected MimeMessage parseInput(InputStream data) {
        try {
            MimeMessage mm = new MimeMessage( getSession(), data );
            log.debug( "encoding: " + mm.getEncoding());
            return mm;
            //return new SMTPMessage(getSession(), data);
        } catch (MessagingException ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here


            public void doEvent(FilterChain chain, Event e) {
                MailboxAddress from = MailboxAddress.parse(event.getFrom());
                MailboxAddress recip = MailboxAddress.parse(event.getRecipient());

                MimeMessage mm = parseInput(data);

                Mailbox recipMailbox = resourceFactory.getMailbox(recip);
                if (recipMailbox != null && !recipMailbox.isEmailDisabled()) {
                    log.debug("recipient is known to us, so store: " + recip);
                    storeMail(recipMailbox,mm);
View Full Code Here

            throw new RuntimeException(ex);
        }
    }
   
    public MimeMessage newMessage() {
        return new MimeMessage(getSession());
    }
View Full Code Here

        MailQue.removeWatcher(this);
    }

    public void sendMail( StandardMessage sm ) {
        StandardMessageFactory smf = new StandardMessageFactoryImpl();
        MimeMessage mm  = newMessage();
        smf.toMimeMessage( sm, mm );
        sendMail( mm );
    }
View Full Code Here

    public void sendMail(String from, String fromPersonal, List<String> to, String replyTo, String subject, String text) {
        if( !started ) {
            throw new RuntimeException("This mail sender is stopped");
        }
        try {
            MimeMessage mm = new MimeMessage(getSession());
            mm.setSubject(subject);
            InternetAddress ia;
            if( fromPersonal == null ) {
                ia = new InternetAddress(from);
            } else {
                ia = new InternetAddress(from, fromPersonal);
            }
            mm.setFrom(ia);
            Address[] add = new Address[1];
            add[0] = new InternetAddress(replyTo);
            mm.setReplyTo(add);
            for (String sTo : to) {
                if( sTo != null && sTo.length() > 0 ) {
                    InternetAddress recip = null;
                    try {
                        recip = new InternetAddress(sTo);
                    } catch (AddressException addressException) {
                        throw new RuntimeException("Couldnt parse email address: " + sTo, addressException);
                    }
                    mm.addRecipient(RecipientType.TO, recip);
                }
            }
            mm.setContent(text, "text/plain");
            sendMail(mm);
        } catch (UnsupportedEncodingException ex) {
            throw new RuntimeException(ex);
        } catch (MessagingException messagingException) {
            throw new RuntimeException(messagingException);
View Full Code Here

        }
    }

    public void sendMail( StandardMessage sm ) {
        StandardMessageFactory smf = new StandardMessageFactoryImpl();
        MimeMessage mm  = newMessage();
        smf.toMimeMessage( sm, mm );
        sendMail( mm );
    }
View Full Code Here

            throw new RuntimeException(ex);
        }
    }
   
    public MimeMessage newMessage() {
        return new MimeMessage(getSession());
    }
View Full Code Here

    /*
     * if the mailhost was not set in the olat_config.xml, we assume that no
     * emailing is wished.
     */
    if (MailHelper.getMailhost() == null || MailHelper.getMailhost().equals("") || ((MailHelper.getMailhost() instanceof String) && ((String)MailHelper.getMailhost()).equalsIgnoreCase("disabled"))) return false;
    MimeMessage msg = MailHelper.createMessage();
    msg.setFrom(new InternetAddress(this.mailfrom));
    msg.setSubject(subject, "utf-8");
    msg.setText(body + footer, "utf-8");
    msg.setSentDate(new Date());
    Iterator iter = listOfContactLists.iterator();
    while (iter.hasNext()) {
      ContactList tmp = (ContactList) iter.next();
      InternetAddress groupName[] = InternetAddress.parse(tmp.getRFC2822Name() + ";");
      InternetAddress members[] = tmp.getEmailsAsAddresses();
      msg.addRecipients(RecipientType.TO, groupName);
      msg.addRecipients(RecipientType.BCC, members);
    }
    msg.saveChanges();
    MailerResult result = new MailerResult();
    MailHelper.sendMessage(msg.getFrom()[0], msg.getRecipients(RecipientType.TO), msg.getRecipients(RecipientType.CC), msg
        .getRecipients(RecipientType.BCC), body + footer, subject, null, result);
    return true;
  }
View Full Code Here

    /*
     * if the mailhost was not set in the olat_config.xml, we assume that no
     * emailing is wished.
     */
    if (MailHelper.getMailhost() == null || MailHelper.getMailhost().equals("") || ((MailHelper.getMailhost() instanceof String) && ((String)MailHelper.getMailhost()).equalsIgnoreCase("disabled"))) return false;
    MimeMessage msg = MailHelper.createMessage();
    msg.setFrom(new InternetAddress(from));
    msg.setRecipients(RecipientType.TO, InternetAddress.parse(mailto));
    msg.setSubject(subject, "utf-8");
    msg.setText(body + footer, "utf-8");
    msg.setSentDate(new Date());
    msg.saveChanges();
    MailerResult result = new MailerResult();
    MailHelper.sendMessage(msg.getFrom()[0], msg.getRecipients(RecipientType.TO), msg.getRecipients(RecipientType.CC), msg
        .getRecipients(RecipientType.BCC), body + footer, subject, null, result);
    return true;
  }
View Full Code Here

    MailerResult result = new MailerResult();

    VelocityContext context = new VelocityContext();   
    template.putVariablesInMailContext(context, recipientTO);
   
    MimeMessage msg = createWithContext(context, recipientTO, recipientsCC, recipientsBCC, template, sender, result);
    String subject=null;
    String body=null;
    try {
      subject = msg.getSubject();
      //
      //assume String because the body text is set via setText(..,"utf-8")
      //in the MailHelper
      //see also http://java.sun.com/j2ee/1.4/docs/api/javax/mail/internet/MimeMessage.html#getContent()
      body = (String)msg.getContent();
    } catch (MessagingException e) {
      result.setReturnCode(MailerResult.TEMPLATE_GENERAL_ERROR);
    } catch (IOException e) {
      result.setReturnCode(MailerResult.TEMPLATE_GENERAL_ERROR);
    }
View Full Code Here

TOP

Related Classes of javax.mail.internet.MimeMessage

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.