Package javax.mail

Examples of javax.mail.Transport.sendMessage()


        Transport transport = null;
         try {
          transport = session.getTransport(outgoingMailServer);
          try {
            transport.connect();
            transport.sendMessage(message, addr);
            if( transport instanceof SMTPTransport )
            {
              String response = ((SMTPTransport)transport).getLastServerResponse();
              if( response != null )
              {
View Full Code Here


            tr.connect(smtpServer, username, password);
        } else {
            tr.connect();
        }

        tr.sendMessage(message, message.getAllRecipients());

        if (synchronousMode) {
            listener.attend(); // listener cannot be null here
        }
View Full Code Here

                            // MX record.  Just log the exception.  We'll worry about
                            // failing the message at the end of the loop.
                            log(me.getMessage());
                            continue;
                        }
                        transport.sendMessage(message, addr);
                    } finally {
                        if (transport != null) {
                            transport.close();
                            transport = null;
                        }
View Full Code Here

          Address[] recipients = email.getAllRecipients();
          if (recipients.length > 0) {
            Transport transport = mailSession.getTransport(recipients[0]);
            try {
              transport.connect();
              transport.sendMessage(email, recipients);
            }
            finally {
              transport.close();
            }
          }
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

            tr.connect(smtpServer, username, password);
        } else {
            tr.connect();
        }

        tr.sendMessage(message, message.getAllRecipients());

        if (synchronousMode) {
            listener.attend(); // listener cannot be null here
        }
View Full Code Here

          message.setFrom(addressFrom);
          message.addRecipient(Message.RecipientType.TO, addressTo);
          message.saveChanges();
          Transport transport = session.getTransport("smtp");
          transport.connect(jTextFieldHost.getText(), jTextFieldName.getText(), new String(jTextFieldPassword.getPassword()));
          transport.sendMessage(message, message.getAllRecipients());
          transport.close();
        }
        catch (Exception e1)
        {
          failure = true;
View Full Code Here

            if (userName != null && password != null) {
                msg.saveChanges(); // implicit with send()
                Transport transport = session.getTransport("smtp");
                transport.connect(mailHost, userName, password);
                transport.sendMessage(msg, msg.getAllRecipients());
                transport.close();
            } else {
                Transport.send(msg);
            }
        } catch (MessagingException e) {
View Full Code Here

   
                if (userName != null && password != null) {
                    msg.saveChanges(); // implicit with send()
                    Transport transport = session.getTransport("smtp");
                    transport.connect(mailHost, userName, password);
                    transport.sendMessage(msg, msg.getAllRecipients());
                    transport.close();
                } else {
                    Transport.send(msg);
                }
               
View Full Code Here

        if (smtpUser != null && smtpUser.length() > 0) {
            trans.connect(smtpHost, smtpUser, smtpPassword);
        } else {
            trans.connect();
        }
        trans.sendMessage(newMessage, newMessage.getRecipients(javax.mail.Message.RecipientType.TO));
        trans.close();
    }

}
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.