How can I flush the mail spooler?


#1

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.


#2

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


#3

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


#4

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


#5

@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.


#6

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


#7

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.