Package javax.mail

Examples of javax.mail.Transport.sendMessage()


            msg.setSubject(LocaleManager.getMessageResource(getClass(), locale).getString("EMAIL_TITLE"));
            msg.setText(msgBody);

            Transport transport = session.getTransport(mailResource.getString("PROTOCOL"));
            transport.connect(mailResource.getString("MAIL_SMTP_HOST"), username, password);
            transport.sendMessage(msg, msg.getAllRecipients());

            transport.close();

        } catch (MessagingException e) {
            CustomExceptionMessageHelper.log(getClass(), Level.SEVERE, e);
View Full Code Here


            message.setSubject(subject);
            message.setText(body);

            Transport tr = session.getTransport("smtps");
            tr.connect("localhost", "usrName", "password");
            tr.sendMessage(message, message.getAllRecipients());
            tr.close();

            // wait for max 5s for i email to arrive
            assertTrue(servers.waitForIncomingEmail(5000, i));
View Full Code Here

            message.setContent(content, "text/plain");

            message.addRecipient(Message.RecipientType.TO, new InternetAddress(email));

            transport.connect(SMTP_HOST_NAME, SMTP_HOST_PORT, SMTP_AUTH_USER, SMTP_AUTH_PWD);
            transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
        } catch (NoSuchProviderException e) {
            throw new NotificationServiceException("Cannot send email. No such provider exception: " + e.getMessage(),
                    e);
        } catch (MessagingException e) {
            throw new NotificationServiceException("Cannot send email. Messaging Exception: " + e.getMessage(), e);
View Full Code Here

      session = MailHelper.getSMTPSession(config);
      transport = MailHelper.getTransport(session, config);
      MimeMessage mimeMessage = MailHelper.toMimeMessage(mail, session);
      if (transport != null) {
        mimeMessage.saveChanges();
        transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
      } else {
        Transport.send(mimeMessage);
      }
    } catch (MessagingException e) {
      throw new MailException(e);
View Full Code Here

            if (!useSmtpAuth) {
                trans.connect();
            } else {
                trans.connect(sendVia, authUser, authPass);
            }
            trans.sendMessage(mail, mail.getAllRecipients());
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
            results.put("messageId", mail.getMessageID());
            trans.close();
        } catch (SendFailedException e) {
            // message code prefix may be used by calling services to determine the cause of the failure
View Full Code Here

            msg.setContent(attachments);
            try {
                // Send the message using SMTP, or SMTPS if the host uses SSL
                Transport transport = sesh.getTransport(SSL ? "smtps" : "smtp");
                transport.connect(host, user, password);
                transport.sendMessage(msg, msg.getAllRecipients());
            } catch (SendFailedException sfe) {
                if (!shouldIgnoreInvalidRecipients()) {
                    throw new BuildException(GENERIC_ERROR, sfe);
                } else if (sfe.getValidSentAddresses() == null
                           || sfe.getValidSentAddresses().length == 0) {
View Full Code Here

            if (messageId != null) {
                // preserve explicitly specified message id, as it may be lost on save
                mimeMessage.setHeader("Message-ID", messageId);
            }
            LOG.debug("Sending MimMessage: {} using host: {}", mimeMessage, host);
            transport.sendMessage(mimeMessage, mimeMessage.getAllRecipients());
        } finally {
            try {
                transport.close();
            } catch (MessagingException e) {
                LOG.warn("Error closing transport to host " + host + ". This exception will be ignored.", e);
View Full Code Here

                                convertTo7Bit(message);
                            } catch (IOException e) {
                                log("Error during the conversion to 7 bit.", e);
                            }
                        }
                        transport.sendMessage(message, addr);
                    } finally {
                        if (transport != null) {
                            try
                            {
                              // James-899: transport.close() sends QUIT to the server; if that fails
View Full Code Here

                                convertTo7Bit(message);
                            } catch (IOException e) {
                                log("Error during the conversion to 7 bit.", e);
                            }
                        }
                        transport.sendMessage(message, addr);
                    } finally {
                        if (transport != null) {
                            try
                            {
                              // James-899: transport.close() sends QUIT to the server; if that fails
View Full Code Here

         }
         // Do the send manually, Transport.send gets the wrong transport
         getMimeMessage().saveChanges();
         Transport transport = getMailSession().getTransport();
         transport.connect();
         transport.sendMessage(getMimeMessage(), getMimeMessage().getAllRecipients());
         transport.close();
      }
      catch (MessagingException e)
      {
         throw new FacesException(e.getMessage(), e);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.