Fix for sending mail from non-server context