Mail Resender
Modifié par superadmin le 2024/12/19 16:54
- Mail Resender
-
Resend emails that were prepared but that were either not sent or that failed to be sent (i.e. all mails in the "prepare_*" states). The mails are resent synchronously one by one to avoid requiring a lot of memory in case a lot of emails need to be resent.
- 0 0 12 * * ?
- Ce script est le code qui sera exécuté lorsque le traitement sera lancé par le planificateur. Il doit être écrit en Groovy. L'API XWiki est accessible via les variables "xwiki" et "context".
- import org.apache.commons.lang3.exception.ExceptionUtils
services.mail.storage.resend(['state' : 'prepare_success'], 0, 0)
if (services.mail.sender.lastError) {
// Send a mail to the administrator with the exception, using the default "from" for both
// the sender and the recipient. If no default from is used then don't send anything.
def from = services.mail.sender.configuration.fromAddress
if (!from) {
def message = services.mail.sender.createMessage(from, from, 'Mail Resender Scheduler Job Failed')
message.addPart('text/plain', """
The following error happened when trying to resend emails:
${ExceptionUtils.getMessage(services.mail.sender.lastError)}
""")
}
}