Mail Resender
Última modificación por Administrador Virtual el 2025/06/11 16:32
- 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_success" state). 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 * * ?
- El script es el código que será ejecutado cuando el planificador lance el trabajo. Debe estar escrito en el lenguaje Groovy. La API de XWiki está disponible mediante de las variables predefinidas xwiki y 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)}
""")
}
}