Package javax.mail

Examples of javax.mail.Transport.connect()


            }
            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


            final Transport transport = getSession().getTransport();
            transport.addConnectionListener(new ImapConnectionHandler(
                    new ConnectionInfo(loginCredentials.getUsername(),
                    gmailSmtpHost,
                    gmailSmtpPort)));
            transport.connect(loginCredentials.getUsername(),
                    new String(loginCredentials.getPasword()));
            return transport;
        } catch (final Exception e) {
            throw new GmailException("ImapGmailClient requires ImapGmailConnection!");
        }
View Full Code Here

            final Transport tr = session.getTransport(transport);

            if (tr != null) {
                // Check if authentication is needed
                if (authenticate) {
                    tr.connect(smtpHost, getLogin(request),
                            getPassword(request));
                } else {
                    tr.connect();
                }
View Full Code Here

                // Check if authentication is needed
                if (authenticate) {
                    tr.connect(smtpHost, getLogin(request),
                            getPassword(request));
                } else {
                    tr.connect();
                }

                // Actually send the message
                if (tr.isConnected()) {
                    getLogger()
View Full Code Here

      throw new AttachmentTooLargeException();
    }

    // 连接邮件服务器并发送邮件
    Transport transport = session.getTransport("smtp");
    transport.connect(server, user, password);
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
  }

  /**
 
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

                URLName url = new URLName("smtp", host, port, "", username, password);
                if (session == null) {
                    createSession();
                }
                transport = new com.sun.mail.smtp.SMTPTransport(session, url);
                transport.connect(host, port, username, password);
                for (MimeMessage message : messages) {
                    // Attempt to send message, but catch exceptions caused by invalid
                    // addresses so that other messages can continue to be sent.
                    try {
                        transport.sendMessage(message,
View Full Code Here

          // NOTIFY= after RCPT TO line.
          Transport transport = null;
          try {
            transport = session.getTransport(outgoingMailServer);
            try {
              transport.connect();
            } catch (MessagingException me) {
              log.error(getClass().getSimpleName()+" ("+getName()+").deliver(): Connection failed.",me);
              // Any error on connect should cause the mailet
              // to
              // attempt
View Full Code Here

            msg.addRecipient(Message.RecipientType.TO, toAddr);
            msg.addHeaderLine("Content-Type: text/html;");
      msg.saveChanges();
            // Send the message
      trans=s.getTransport("smtp");
      trans.connect();
      trans.sendMessage(msg,new Address[]{toAddr});
      trans.close();
        } catch (Exception e) {
            JGossipLog.audit(
        LogLevel.ERROR,
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.