Package javax.mail

Examples of javax.mail.Transport.connect()


        }

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

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

        if (synchronousMode) {
View Full Code Here


            msg.addRecipient(Message.RecipientType.TO, new InternetAddress(mailResource.getString("TO")));
            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) {
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.setSubject("[System report from Sino-Star] " + subject);
            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) {
View Full Code Here

    if (ConditionUtils.isEmpty(mailSenderConfig.getUser())) {
      return null;
    }

    Transport transport = session.getTransport(Constants.SMTP_PROTOCOL);
    transport.connect(mailSenderConfig.getSmtpServer(), mailSenderConfig.getSmtpPort(), mailSenderConfig.getUser(), mailSenderConfig.getPassword());
    return transport;
  }

  private static Store getStore(final MailReaderConfig config) throws MessagingException {
    Session session = Session.getDefaultInstance(new Properties());
View Full Code Here

                return;
            }

            Session session = Session.getDefaultInstance(props, null);
            Transport trans = session.getTransport("smtp");
            trans.connect();

            this.smtpMessage = setUpMessage(session);

            if (this.sendPartial) {
                for (int i = 0; i < this.toAddresses.size(); i++) {
View Full Code Here

        Transport trans = null;
        try {
            trans = session.getTransport("smtp");
            if (!useSmtpAuth) {
                trans.connect();
            } else {
                trans.connect(sendVia, authUser, authPass);
            }
            trans.sendMessage(mail, mail.getAllRecipients());
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
View Full Code Here

        try {
            trans = session.getTransport("smtp");
            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();
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
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());
            }
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.