Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-12068

Add reporting for mails that fail to be prepared

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 7.1-rc-1
    • 6.4
    • Mail
    • None
    • Unit
    • Unknown

    Description

      Right now we have:

      public interface MailListener
      {
          /**
           * Called when the mail is ready to be sent but before it is actually sent.
           *
           * @param message the message to be sent
           * @param parameters some parameters specifying addition context data (for example the current wiki is stored under
           *        the {@code wiki} key)
           */
          void onPrepare(MimeMessage message, Map<String, Object> parameters);
      
          /**
           * Called when the mail has been sent successfully.
           *
           * @param message the message sent
           * @param parameters some parameters specifying addition context data (for example the current wiki is stored under
           *        the {@code wiki} key)
           */
          void onSuccess(MimeMessage message, Map<String, Object> parameters);
      
          /**
           * Called when the mail has failed to be sent.
           *
           * @param message the message that was tried to be sent
           * @param e the exception explaining why the message couldn't be sent
           * @param parameters some parameters specifying addition context data (for example the current wiki is stored under
           *        the {@code wiki} key)
           */
          void onError(MimeMessage message, Exception e, Map<String, Object> parameters);
      

      If a mail fails to be prepared, it's only reported in the logs but it won't appear in the Mail Admin Status UI. This can happen for example if a template mails fails to evaluated (because some of the java api called throw an exception!).

      Proposal:

      • Add a new event in MailListener
      • Display mails failing to be prepared in the Mail Admin Status UI

      For example:

      public interface MailListener
      {
          void onPrepareSuccess(MimeMessage message, Map<String, Object> parameters);
          void onPrepareError(Exception e, Map<String, Object> parameters);
          void onSendSuccess(MimeMessage message, Map<String, Object> parameters);
          void onSendError(MimeMessage message, Exception e, Map<String, Object> parameters);
      }
      

      Alternative:

      public interface MailPrepareListener
      {
          void onSuccess(MimeMessage message, Map<String, Object> parameters);
          void onError(Exception e, Map<String, Object> parameters);
      }
      
      public interface MailSendListener
      {
          void onSuccess(MimeMessage message, Map<String, Object> parameters);
          void onError(MimeMessage message, Exception e, Map<String, Object> parameters);
      }
      

      Attachments

        Issue Links

          Activity

            People

              softec Denis Gervalle
              vmassol Vincent Massol
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: