Package javax.mail

Examples of javax.mail.Transport.connect()


             System.setProperty("mail.smtp.port", this.port);
             System.setProperty("mail.smtp.host", this.host);
             if ( this.user.length()==0) {
                t.connect();
             }else {
                 t.connect(this.host,this.user,this.password);
             }
             t.sendMessage(message,message.getAllRecipients());
             t.close();

            
View Full Code Here


        }
       
        message.setSubject(subject);
        message.setText(emailBody.toString());
        Transport transport = session.getTransport("smtp");
        transport.connect(host, from, pass);
        transport.sendMessage(message, message.getAllRecipients());
        transport.close();
     
     }catch(MessagingException ex)
     {
View Full Code Here

  protected void send(final Session session, final MimeMessage msg) {
    try {
      final URLName smtpUrlName = options.genSmtpUrlName();
      log.debug("Opening transport to: " + smtpUrlName);
      final Transport transport = session.getTransport(smtpUrlName);
      transport.connect(smtpUrlName.getHost(), smtpUrlName.getPort(),
          smtpUrlName.getUsername(), smtpUrlName.getPassword());
      transport.sendMessage(msg, msg.getAllRecipients());
      transport.close();
      log.info("Message sent");
    } catch (Exception e) {
View Full Code Here

        msg.setSubject(subject);
        msg.setContent(multipart);
       
        Transport transport = session.getTransport(addressTo[0]);
        transport.addTransportListener(this);
        transport.connect();
        // Sending Message
        for(Address to: addressTo) {
          try{
          //msg.setRecipients(RecipientType.TO,new Address[]{to});
          //Transport.send(msg);
View Full Code Here

            msg.setRecipients(RecipientType.TO,new Address[]{to});
            transport.sendMessage(msg,new Address[]{to});
          } catch (Exception e) {
            //messageSendFailed(e,msg);
            transport.close();
                transport.connect();
          }
        }
        transport.close();
    }
View Full Code Here

      props.put("mail.transport.protocol", this.protocol);
      props.put("mail." + this.protocol + ".host", this.smtpHost);
      props.put("mail." + this.protocol + ".port", String.valueOf(this.port));
      Session session = Session.getDefaultInstance(props, null);
      transport = session.getTransport(this.protocol);
      transport.connect(this.smtpHost, this.userName, this.passWord);
     
      for (int i = 0; i < mailMessage.length; ++i) {
        mailMessage[i].setSession(session);
        transport.sendMessage(mailMessage[i].getMessage(),mailMessage[i].getMessage().getAllRecipients());
      }
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

        Properties props = this.prepareProperties(smtpServer, port, username, password, "true");
        Session mailSession = Session.getDefaultInstance(props, new SMTPAuthenticator(from, password, true));
        transport = mailSession.getTransport("smtp");
        MimeMessage message = this.prepareMessage(mailSession,"ISO-8859-2", from, subject, msg, recipient);
        transport.connect();
        Transport.send(message);

            return 0;
     }
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

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.