XWiki Platform
  1. XWiki Platform
  2. XWIKI-12068

Add reporting for mails that fail to be prepared

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 6.4
    • Fix Version/s: 7.1-rc-1
    • Component/s: Mail
    • Labels:
      None
    • Tests:
      Unit
    • Difficulty:
      Unknown
    • Similar issues:

      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);
      }
      

        Issue Links

          Activity

          There are no comments yet on this issue.

            People

            • Assignee:
              Denis Gervalle
              Reporter:
              Vincent Massol
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: