Background sending of emails

Now including tests!
Trailing whitespace detected.