Search in sources :

Example 1 with SmtpTransport

use of com.zimbra.cs.mailclient.smtp.SmtpTransport in project zm-mailbox by Zimbra.

the class DataSourceManager method test.

/*
     * Tests connecting to a data source.  Do not actually create the
     * data source.
     */
public static void test(DataSource ds) throws ServiceException {
    ZimbraLog.datasource.info("Testing: %s", ds);
    try {
        DataImport di = getInstance().getDataImport(ds, true);
        di.test();
        if (ds.isSmtpEnabled()) {
            Session session = JMSession.getSession(ds);
            Transport smtp = session.getTransport();
            String emailAddress = ds.getEmailAddress();
            if (smtp instanceof SmtpTransport) {
                test((SmtpTransport) smtp, emailAddress);
            } else {
                test((SMTPTransport) smtp, emailAddress);
            }
        }
        ZimbraLog.datasource.info("Test succeeded: %s", ds);
    } catch (ServiceException x) {
        ZimbraLog.datasource.info("Test failed: %s", ds, x);
        throw x;
    } catch (Exception e) {
        ZimbraLog.datasource.info("Test failed: %s", ds, e);
        throw ServiceException.INVALID_REQUEST("Datasource test failed", e);
    }
}
Also used : DataImport(com.zimbra.cs.account.DataSource.DataImport) ServiceException(com.zimbra.common.service.ServiceException) SmtpTransport(com.zimbra.cs.mailclient.smtp.SmtpTransport) Transport(javax.mail.Transport) SmtpTransport(com.zimbra.cs.mailclient.smtp.SmtpTransport) SMTPTransport(com.sun.mail.smtp.SMTPTransport) MessagingException(javax.mail.MessagingException) ServiceException(com.zimbra.common.service.ServiceException) JMSession(com.zimbra.cs.util.JMSession) Session(javax.mail.Session)

Aggregations

SMTPTransport (com.sun.mail.smtp.SMTPTransport)1 ServiceException (com.zimbra.common.service.ServiceException)1 DataImport (com.zimbra.cs.account.DataSource.DataImport)1 SmtpTransport (com.zimbra.cs.mailclient.smtp.SmtpTransport)1 JMSession (com.zimbra.cs.util.JMSession)1 MessagingException (javax.mail.MessagingException)1 Session (javax.mail.Session)1 Transport (javax.mail.Transport)1