Examples of MailException


Examples of play.exceptions.MailException

                    try {
                        msg.setSentDate(new Date());
                        msg.send();
                        return true;
                    } catch (Throwable e) {
                        MailException me = new MailException("Error while sending email", e);
                        Logger.error(me, "The email has not been sent");
                        return false;
                    }
                }
            });
        } else {
            final StringBuffer result = new StringBuffer();
            try {
                msg.setSentDate(new Date());
                msg.send();
            } catch (Throwable e) {
                MailException me = new MailException("Error while sending email", e);
                Logger.error(me, "The email has not been sent");
                result.append("oops");
            }
            return new Future<Boolean>() {
View Full Code Here

Examples of play.exceptions.MailException

    public static Future<Boolean> send(Email email) {
        try {
            email = buildMessage(email);
            return currentMailSystem().sendMessage(email);
        } catch (EmailException ex) {
            throw new MailException("Cannot send email", ex);
        }
    }
View Full Code Here

Examples of play.exceptions.MailException

        String from = Play.configuration.getProperty("mail.smtp.from");
        if (email.getFromAddress() == null && !StringUtils.isEmpty(from)) {
            email.setFrom(from);
        } else if (email.getFromAddress() == null) {
            throw new MailException("Please define a 'from' email address", new NullPointerException());
        }
        if ((email.getToAddresses() == null || email.getToAddresses().size() == 0) &&
            (email.getCcAddresses() == null || email.getCcAddresses().size() == 0&&
            (email.getBccAddresses() == null || email.getBccAddresses().size() == 0))
        {
            throw new MailException("Please define a recipient email address", new NullPointerException());
        }
        if (email.getSubject() == null) {
            throw new MailException("Please define a subject", new NullPointerException());
        }
        if (email.getReplyToAddresses() == null || email.getReplyToAddresses().size() == 0) {
            email.addReplyTo(email.getFromAddress().getAddress());
        }
View Full Code Here

Examples of play.exceptions.MailException

                    try {
                        msg.setSentDate(new Date());
                        msg.send();
                        return true;
                    } catch (Throwable e) {
                        MailException me = new MailException("Error while sending email", e);
                        Logger.error(me, "The email has not been sent");
                        return false;
                    }
                }
            });
        } else {
            final StringBuffer result = new StringBuffer();
            try {
                msg.setSentDate(new Date());
                msg.send();
            } catch (Throwable e) {
                MailException me = new MailException("Error while sending email", e);
                Logger.error(me, "The email has not been sent");
                result.append("oops");
            }
            return new Future<Boolean>() {
View Full Code Here

Examples of play.exceptions.MailException

                    } catch (Exception e) {
                        email.addTo(recipient.toString());
                    }
                }
            } else {
                throw new MailException("You must specify at least one recipient.");
            }


            List<Object> ccsList = (List<Object>) infos.get().get("ccs");
            if (ccsList != null) {
                for (Object cc : ccsList) {
                    email.addCc(cc.toString());
                }
            }

            List<Object> bccsList = (List<Object>) infos.get().get("bccs");
            if (bccsList != null) {

                for (Object bcc : bccsList) {
                    try {
                        InternetAddress iAddress = new InternetAddress(bcc.toString());
                        email.addBcc(iAddress.getAddress(), iAddress.getPersonal());
                    } catch (Exception e) {
                        email.addBcc(bcc.toString());
                    }
                }
            }
            if (!StringUtils.isEmpty(charset)) {
                email.setCharset(charset);
            }

            email.setSubject(subject);
            email.updateContentType(contentType);

            if (headers != null) {
                for (String key : headers.keySet()) {
                    email.addHeader(key, headers.get(key));
                }
            }

            return Mail.send(email);
        } catch (EmailException ex) {
            throw new MailException("Cannot send email", ex);
        }
    }
View Full Code Here

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

Examples of railo.runtime.net.mail.MailException

 
 
  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

Examples of railo.runtime.net.mail.MailException

          }
          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

Examples of yalp.exceptions.MailException

            }

            email.setMailSession(getSession());
            return sendMessage(email);
        } catch (EmailException ex) {
            throw new MailException("Cannot send email", ex);
        }
    }
View Full Code Here

Examples of yalp.exceptions.MailException

        String from = Yalp.configuration.getProperty("mail.smtp.from");
        if (email.getFromAddress() == null && !StringUtils.isEmpty(from)) {
            email.setFrom(from);
        } else if (email.getFromAddress() == null) {
            throw new MailException("Please define a 'from' email address", new NullPointerException());
        }
        if ((email.getToAddresses() == null || email.getToAddresses().size() == 0) &&
                (email.getCcAddresses() == null || email.getCcAddresses().size() == 0) &&
                (email.getBccAddresses() == null || email.getBccAddresses().size() == 0)) {
            throw new MailException("Please define a recipient email address", new NullPointerException());
        }
        if (email.getSubject() == null) {
            throw new MailException("Please define a subject", new NullPointerException());
        }
        if (email.getReplyToAddresses() == null || email.getReplyToAddresses().size() == 0) {
            email.addReplyTo(email.getFromAddress().getAddress());
        }
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.