Package javax.mail

Examples of javax.mail.Transport


        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

    }
View Full Code Here


        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

    }
View Full Code Here

        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

    }
View Full Code Here

        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

    }
View Full Code Here

        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

        TestTransport testTransport = (TestTransport) transport;
        assertFalse(testTransport.isEHLO());
View Full Code Here

        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

    }
View Full Code Here

        Store store = ((Session) proxy).getStore();
        assertNotNull(store);
        assertTrue(store instanceof TestStore);

        Transport transport = ((Session) proxy).getTransport();
        assertNotNull(transport);
        assertTrue(transport instanceof TestTransport);

    }
View Full Code Here

     * Sending mails via web
     */
    public int sendEmail(String from, String password, String subject, String msg, String recipient, String smtpServer, String port, String username)
            throws NoSuchProviderException, MessagingException {

        Transport transport = null;

        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

            Debug.logVerbose("What would have been sent, the addressee: " + sendTo + " subject: " + subject + " context: " + context, module);
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
            return results;
        }

        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));
            results.put("messageId", mail.getMessageID());
            trans.close();
        } catch (SendFailedException e) {
            // message code prefix may be used by calling services to determine the cause of the failure
            String errMsg = "[ADDRERR] Address error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]";
            Debug.logError(e, errMsg, module);
            List<SMTPAddressFailedException> failedAddresses = FastList.newInstance();
            Exception nestedException = null;
            while ((nestedException = e.getNextException()) != null && nestedException instanceof MessagingException) {
                if (nestedException instanceof SMTPAddressFailedException) {
                    SMTPAddressFailedException safe = (SMTPAddressFailedException) nestedException;
                    Debug.logError("Failed to send message to [" + safe.getAddress() + "], return code [" + safe.getReturnCode() + "], return message [" + safe.getMessage() + "]", errMsg);
                    failedAddresses.add(safe);
                    break;
                }
            }
            Boolean sendFailureNotification = (Boolean) context.get("sendFailureNotification");
            if (sendFailureNotification == null || sendFailureNotification) {
                sendFailureNotification(ctx, context, mail, failedAddresses);
                results.put("messageWrapper", new MimeMessageWrapper(session, mail));
                try {
                    results.put("messageId", mail.getMessageID());
                    trans.close();
                } catch (MessagingException e1) {
                    Debug.logError(e1, module);
                }
            } else {
                return ServiceUtil.returnError(errMsg);
View Full Code Here

            Debug.logVerbose("What would have been sent, the addressee: " + sendTo + " subject: " + subject + " context: " + context, module);
            results.put("messageWrapper", new MimeMessageWrapper(session, mail));
            return results;
        }

        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));
            results.put("messageId", mail.getMessageID());
            trans.close();
        } catch (SendFailedException e) {
            // message code prefix may be used by calling services to determine the cause of the failure
            Debug.logError(e, "[ADDRERR] Address error when sending message to [" + sendTo + "] from [" + sendFrom + "] cc [" + sendCc + "] bcc [" + sendBcc + "] subject [" + subject + "]", module);
            List<SMTPAddressFailedException> failedAddresses = FastList.newInstance();
            Exception nestedException = null;
            while ((nestedException = e.getNextException()) != null && nestedException instanceof MessagingException) {
                if (nestedException instanceof SMTPAddressFailedException) {
                    SMTPAddressFailedException safe = (SMTPAddressFailedException) nestedException;
                    Debug.logError("Failed to send message to [" + safe.getAddress() + "], return code [" + safe.getReturnCode() + "], return message [" + safe.getMessage() + "]", module);
                    failedAddresses.add(safe);
                    break;
                }
            }
            Boolean sendFailureNotification = (Boolean) context.get("sendFailureNotification");
            if (sendFailureNotification == null || sendFailureNotification) {
                sendFailureNotification(ctx, context, mail, failedAddresses);
                results.put("messageWrapper", new MimeMessageWrapper(session, mail));
                try {
                    results.put("messageId", mail.getMessageID());
                    trans.close();
                } catch (MessagingException e1) {
                    Debug.logError(e1, module);
                }
            } else {
                return ServiceUtil.returnError(UtilProperties.getMessage(resource, "CommonEmailSendAddressError", UtilMisc.toMap("sendTo", sendTo, "sendFrom", sendFrom, "sendCc", sendCc, "sendBcc", sendBcc, "subject", subject), locale));
View Full Code Here

TOP

Related Classes of javax.mail.Transport

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.