How can I flush the mail spooler?

When running a task in commandbox, I want to flush the email spooler to ensure that all emails that were generated in my task are delivered. Is this possible?

I’m execute the commandbox task using cfexecute, which launches commandbox in a new process. What can happen is that emails can get stuck in the spool and not delivered until the next time commandbox is launched.

I don’t think that’s available, it’s a good idea for a feature request, file an enhancement request in jira?

Either that, or it might be something that commandbox needs do after the process exits.

I may have solved it by using the asyc=false in for cfmail. It appears that using that flag will not create a task.

@Redtopia I asked Micha today (We’re at CFCamp in Germany together) and he said disabling the spooler is probably the easiest way since it will send immediately. I assume setting async to false does exactly that.

If you test and this works, please send me a pull request to the CommandBox Task Runner docs. That’s a good note to keep handy. I’ll also check and see if there’s a setting I can put in CommandBox by default to not spool E-mails.

1 Like

So disabling the spooler during shutdown, will that block shutdown?

No, I don’t think it does. It doesn’t in commandbox. The async argument in cfmail, when set to false, will not use the spool.