Package javax.mail

Examples of javax.mail.Transport.connect()


            addContentToMessage(message, msg);

            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


                addContentToMessage(message, msg);
   
                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

        newMessage.setSentDate(new Date());
        newMessage.setText(content);
        Transport trans = sendMailSession.getTransport("smtp");

        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

        Transport trans = sendMailSession.getTransport("smtp");

        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

       
        if (type == ConfigurationType.MAIL_PROPERTIES) {
            // Configure transport ourselves using mail properties
            transport = session.getTransport("smtp");
            if (mailUsername != null && mailPassword != null && mailPort != -1) {
                transport.connect(mailHostname, mailPort, mailUsername, mailPassword);
            } else if (mailUsername != null && mailPassword != null) {
                transport.connect(mailHostname, mailUsername, mailPassword);
            } else {
                transport.connect();
            }
View Full Code Here

            // Configure transport ourselves using mail properties
            transport = session.getTransport("smtp");
            if (mailUsername != null && mailPassword != null && mailPort != -1) {
                transport.connect(mailHostname, mailPort, mailUsername, mailPassword);
            } else if (mailUsername != null && mailPassword != null) {
                transport.connect(mailHostname, mailUsername, mailPassword);
            } else {
                transport.connect();
            }
        } else {
            // Assume container set things up properly
View Full Code Here

            if (mailUsername != null && mailPassword != null && mailPort != -1) {
                transport.connect(mailHostname, mailPort, mailUsername, mailPassword);
            } else if (mailUsername != null && mailPassword != null) {
                transport.connect(mailHostname, mailUsername, mailPassword);
            } else {
                transport.connect();
            }
        } else {
            // Assume container set things up properly
            transport = session.getTransport();
            transport.connect();
View Full Code Here

                transport.connect();
            }
        } else {
            // Assume container set things up properly
            transport = session.getTransport();
            transport.connect();
        }
       
        return transport;
    }
   
View Full Code Here

    @Override
    public void send(MimeMessage mimeMessage) throws MessagingException {
        Transport transport = getTransport(getSession());
        LOG.debug("Connecting to {}:{}", host, port);
        transport.connect(getHost(), getPort(), getUsername(), getPassword());
        try {
            if (mimeMessage.getSentDate() == null) {
                mimeMessage.setSentDate(new Date());
            }
            String messageId = mimeMessage.getMessageID();
View Full Code Here

        throw new RuntimeException(e);
      }
      Transport transport;
      try {
        transport = session.getTransport();
        transport.connect();
        log.debug("connected");
      } catch (MessagingException e) {
        log.error("Opening transport: ", e);
        throw new RuntimeException("Opening Transport", 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.