Search in sources :

Example 6 with ISMTPSettings

use of com.helger.smtp.settings.ISMTPSettings in project phoss-directory by phax.

the class AppInternalErrorHandler method doSetup.

public static void doSetup() {
    // Set global internal error handlers
    new AppInternalErrorHandler().install();
    final NamedSMTPSettings aNamedSettings = PhotonCoreManager.getSMTPSettingsMgr().getSettings(CNamedSMTPSettings.NAMED_SMTP_SETTINGS_DEFAULT_ID);
    final ISMTPSettings aSMTPSettings = aNamedSettings == null ? null : aNamedSettings.getSMTPSettings();
    InternalErrorSettings.setSMTPSenderAddress(new EmailAddress("pd@helger.com", CPDPublisher.getApplicationTitle()));
    InternalErrorSettings.setSMTPReceiverAddress(new EmailAddress("philip@helger.com", "Philip"));
    InternalErrorSettings.setSMTPSettings(aSMTPSettings);
    InternalErrorSettings.setFallbackLocale(AppCommonUI.DEFAULT_LOCALE);
}
Also used : ISMTPSettings(com.helger.smtp.settings.ISMTPSettings) EmailAddress(com.helger.commons.email.EmailAddress) NamedSMTPSettings(com.helger.photon.core.smtp.NamedSMTPSettings) CNamedSMTPSettings(com.helger.photon.core.smtp.CNamedSMTPSettings)

Example 7 with ISMTPSettings

use of com.helger.smtp.settings.ISMTPSettings in project ph-web by phax.

the class FailedMailDataTest method testWithData.

@Test
public void testWithData() {
    final ISMTPSettings aSettings = _createSMTPSettings();
    final EmailData aData = _createEmailData();
    final FailedMailData aFMD = new FailedMailData(aSettings, aData);
    assertNotNull(aFMD.getID());
    assertNotNull(aFMD.getErrorDateTime());
    assertEquals(aSettings, aFMD.getSMTPSettings());
    assertEquals(aData.getSentDateTime(), aFMD.getOriginalSentDateTime());
    assertEquals(aData, aFMD.getEmailData());
    assertFalse(aFMD.hasTransportError());
    assertNull(aFMD.getTransportThrowableMessage());
    assertNull(aFMD.getTransportError());
    XMLTestHelper.testMicroTypeConversion(aFMD);
}
Also used : ISMTPSettings(com.helger.smtp.settings.ISMTPSettings) EmailData(com.helger.smtp.data.EmailData) Test(org.junit.Test)

Example 8 with ISMTPSettings

use of com.helger.smtp.settings.ISMTPSettings in project ph-web by phax.

the class MailQueuePerSMTP method stopQueuingNewObjects.

/**
 * Stop this queue
 *
 * @param bStopImmediately
 *        <code>true</code> if all mails currently in the queue should be
 *        removed and put in the failed mail queue. Only the emails currently
 *        in sending are continued to be sent out.
 * @return {@link ESuccess}
 */
@Nonnull
public ESuccess stopQueuingNewObjects(final boolean bStopImmediately) {
    if (bStopImmediately) {
        // Remove all mails from the queue and put it in the failed mail queue
        final ICommonsList<Object> aLeftOvers = new CommonsArrayList<>();
        m_aQueue.drainTo(aLeftOvers);
        if (!aLeftOvers.isEmpty()) {
            final ISMTPSettings aSMTPSettings = getSMTPSettings();
            for (final Object aLeftOver : aLeftOvers) m_aFailedMailQueue.add(new FailedMailData(aSMTPSettings, (IMutableEmailData) aLeftOver));
            if (LOGGER.isInfoEnabled())
                LOGGER.info("Put " + aLeftOvers + " unsent mails into the failed mail queue because of immediate stop.");
        }
    }
    // Regular stop
    return super.stopQueuingNewObjects();
}
Also used : FailedMailData(com.helger.smtp.failed.FailedMailData) ISMTPSettings(com.helger.smtp.settings.ISMTPSettings) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) Nonnull(javax.annotation.Nonnull)

Aggregations

ISMTPSettings (com.helger.smtp.settings.ISMTPSettings)8 MailTransportError (com.helger.smtp.transport.MailTransportError)3 Test (org.junit.Test)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 EmailAddress (com.helger.commons.email.EmailAddress)2 MockException (com.helger.commons.exception.mock.MockException)2 CNamedSMTPSettings (com.helger.photon.core.smtp.CNamedSMTPSettings)2 NamedSMTPSettings (com.helger.photon.core.smtp.NamedSMTPSettings)2 EmailData (com.helger.smtp.data.EmailData)2 IMutableEmailData (com.helger.smtp.data.IMutableEmailData)2 FailedMailData (com.helger.smtp.failed.FailedMailData)2 ICommonsOrderedMap (com.helger.commons.collection.impl.ICommonsOrderedMap)1 ESMTPErrorCode (com.helger.smtp.transport.ESMTPErrorCode)1 MailSendDetails (com.helger.smtp.transport.MailSendDetails)1 IMicroElement (com.helger.xml.microdom.IMicroElement)1 LocalDateTime (java.time.LocalDateTime)1 Map (java.util.Map)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1