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

Mails sent with a listener other than the database one are never removed from the mail content store

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 17.10.15
    • Mail
    • Unknown

    Description

      Every mail sent through the Mail Sender API is first serialized to <permanent directory>/mails/<batch id>/<message id> (see PrepareMailRunnable). The only code removing that file after a successful send is DatabaseMailListener#onSendMessageSuccess, so any mail sent with another MailListener leaves its file behind forever.

      This is what happens with the most common script API: $services.mail.sender.send($message) and send($messages) use the memory listener. Since there is no matching entry in the mailsender_events table, these files don't appear in the Mail Sending Status administration either, so the only way to notice is to look at the permanent directory (which keeps growing, attachments included).

      Steps to reproduce

      1. Configure a working SMTP server
      2. Send a mail from a wiki page with Programming right:
        {{velocity}}
        #set ($message = $services.mail.sender.createMessage('from@example.org', 'to@example.org', 'test'))
        #set ($discard = $message.addPart('text/plain', 'test'))
        #set ($result = $services.mail.sender.send($message))
        $result.statusResult.isProcessed()
        {{/velocity}}
        
      3. Look at <permanent directory>/mails/

      Expected

      The mail being successfully sent, nothing remains in <permanent directory>/mails/.

      Actual

      A <batch id>/<message id> file containing the full serialized mail remains, and it's not listed in the Mail Sending Status administration. The same happens for a failed send with such listener, while nothing can resend it (there is no status to resend from).

      Real case: the Invoices application left one file per invoice mail sent (with the PDF attached) during years.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tmortagne Thomas Mortagne
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: