Package railo.runtime.net.mail

Examples of railo.runtime.net.mail.MailException


    index=server.indexOf(':');
    if(index!=-1) {
      try {
        port=Caster.toIntValue(server.substring(index+1));
      } catch (ExpressionException e) {
        throw new MailException(e.getMessage());
      }
      server=server.substring(0,index);
    }
   
   
View Full Code Here


 
 
  public void send(ConfigWeb config) throws MailException {
    if(ArrayUtil.isEmpty(config.getMailServers()) && ArrayUtil.isEmpty(host))
      throw new MailException("no SMTP Server defined");
   
    if(plainText==null && htmlText==null)
      throw new MailException("you must define plaintext or htmltext");
   
    ///if(timeout<1)timeout=config.getMailTimeout()*1000;
    if(spool==SPOOL_YES || (spool==SPOOL_UNDEFINED && config.isMailSpoolEnable())) {
          config.getSpoolerEngine().add(new MailSpoolerTask(this));
        }
View Full Code Here

          }
          servers=nServers;
        }
    if(servers.length==0) {
      //return;
      throw new MailException("no SMTP Server defined");
    }
   
    boolean _ssl,_tls;
    for(int i=0;i<servers.length;i++) {

      Server server = servers[i];
      String _username=null,_password="";
      //int _port;
     
      // username/password
     
      if(server.hasAuthentication()) {
        _username=server.getUsername();
        _password=server.getPassword();
      }
     
     
      // tls
      if(tls!=TLS_NONE)_tls=tls==TLS_YES;
      else _tls=((ServerImpl)server).isTLS();
 
      // ssl
      if(ssl!=SSL_NONE)_ssl=ssl==SSL_YES;
      else _ssl=((ServerImpl)server).isSSL();
     
     
      MimeMessageAndSession msgSess;
     
      synchronized(LOCK) {
        try {
          msgSess = createMimeMessage(config,server.getHostName(),server.getPort(),_username,_password,_tls,_ssl);
        } catch (MessagingException e) {
          // listener
          listener(config,server,log,e,System.nanoTime()-start);
          MailException me = new MailException(e.getMessage());
          me.setStackTrace(e.getStackTrace());
          throw me;
        }
        try {
                SerializableObject lock = new SerializableObject();
                SMTPSender sender=new SMTPSender(lock,msgSess,server.getHostName(),server.getPort(),_username,_password);
                sender.start();
                SystemUtil.wait(lock, _timeout);
               
                if(!sender.hasSended()) {
                    Throwable t = sender.getThrowable();
                    if(t!=null) throw Caster.toPageException(t);
                   
                    // stop when still running
                    try{
                      if(sender.isAlive())sender.stop();
                    }
                    catch(Throwable t2){}
                   
                    // after thread s stopped check send flag again
                    if(!sender.hasSended()){
                      throw new MessagingException("timeout occurred after "+(_timeout/1000)+" seconds while sending mail message");
                    }
                  }
                  clean(config,attachmentz);
                 
                  listener(config,server,log,null,System.nanoTime()-start);
                  break;
        }
              catch (Exception e) {e.printStackTrace();
          if(i+1==servers.length) {
           
            listener(config,server,log,e,System.nanoTime()-start);
            MailException me = new MailException(server.getHostName()+" "+LogUtil.toMessage(e)+":"+i);
            me.setStackTrace(e.getStackTrace());
           
            throw me;
                  }
        }
      }
View Full Code Here

TOP

Related Classes of railo.runtime.net.mail.MailException

Copyright © 2018 www.massapicom. 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.