public static Future<Boolean> send(Email email) {
        try {
            email = buildMessage(email);

            if (GojaConfig.getProperty("mail.smtp", StringPool.EMPTY).equals("mock")
                    && GojaConfig.getApplicationMode().isDev()) {
                Mock.send(email);
                return new Future<Boolean>() {
                    @Override
                    public boolean cancel(boolean mayInterruptIfRunning) {
                        return false;
                    }

                    @Override
                    public boolean isCancelled() {
                        return false;
                    }

                    @Override
                    public boolean isDone() {
                        return true;
                    }

                    @Override
                    public Boolean get() throws InterruptedException, ExecutionException {
                        return true;
                    }

                    @Override
                    public Boolean get(long timeout, final TimeUnit unit)
                            throws InterruptedException, ExecutionException, TimeoutException {
                        return true;
                    }
                };
            }

            email.setMailSession(getSession());
            return sendMessage(email);
        } catch (EmailException ex) {
            throw new MailException("Cannot send email", ex);
        }
    }
public static Future < Boolean > send ( Email email ) { try { email = buildMessage ( email ) ; if ( GojaConfig . getProperty ( "mail.smtp" , StringPool . EMPTY ) . equals ( "mock" ) && GojaConfig . getApplicationMode ( ) . isDev ( ) ) { Mock . send ( email ) ; return new Future < Boolean > ( ) { @ Override public boolean cancel ( boolean mayInterruptIfRunning ) { return false ; } @ Override public boolean isCancelled ( ) { return false ; } @ Override public boolean isDone ( ) { return true ; } @ Override public Boolean get ( ) throws InterruptedException , ExecutionException { return true ; } @ Override public Boolean get ( long timeout , final TimeUnit unit ) throws InterruptedException , ExecutionException , TimeoutException { return true ; } } ; } email . setMailSession ( getSession ( ) ) ; return sendMessage ( email ) ; } catch ( EmailException ex ) { throw new MailException ( "Cannot send email" , ex ) ; } }
Send an email