Fixed an issue where `site.domain` returned 127.0.0.1 rather than the URL in the email subject and template.  This is an issue when running uwsgi/Gunicorn behind a proxy server like Nginx.  Now we allow `site.domain` to be obtained  from the database value first (if it exists) then from the url if it doesn't.