Close connection to db after send_mail command to prevent psql 'unexpected EOF on client connection with an open transaction' error
Ensure db connection is closed for retry_deferred
merge with jacinda fork