python 3.x - Testing Django Email for error handling reporting -


i'd setup automated mailing system notifies admin user when exception has been raised in django app. now, i'd test email notification system , have followed numerous tutorials , tips here , here , here , here, in addition few other sites.

i'm using local django development environment (not in live production scenario), python 3.5 , django 1.8. on home network (no proxy involved etc.)

settings.py

admins = (     ('my name', 'myhotmailaccount@hotmail.com'), ) #email_backend = 'django.core.mail.backends.smtp.emailbackend' mailer_list = ['myhotmailaccount@hotmail.com'] email_host = 'smtp.live.com' email_host_user = 'myhotmailaccount@hotmail.com' email_host_password = 'myhotmail_password' email_port = 465 email_use_tls = true default_from_email = 'noreply@hotmail.com'  logging = {     'version': 1,     'disable_existing_loggers': true,     'formatters': {         'standard': {             'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",             'datefmt' : "%d/%b/%y %h:%m:%s"         },     },     'handlers': {         'default': {             'level':'debug',             'class':'logging.handlers.rotatingfilehandler',             'filename': site_root + "/logfile.log",             'maxbytes': 1024*1024*5, #5 mb             'backupcount': 5,             'formatter': 'standard',         },         'request_handler':{             'level':'debug',             'class':'logging.handlers.rotatingfilehandler',             'filename': site_root + "/django_request.log",             'maxbytes': 1024*1024*5, #5 mb             'backupcount': 2,             'formatter': 'standard'         },         'mail_admins': {             'level': 'error',             'class': 'django.utils.log.adminemailhandler',         }     },     'loggers': {         '': {             'handlers':['mail_admins', 'default'],             'level':'debug',             'propagate': true,         },         'django.request': {             'handlers': ['request_handler'],             'level': 'debug',             'propagate': false,         },         'django': {             'handlers': ['request_handler', 'default', 'mail_admins',],             'propagate': true,             'level': 'debug',         },     } } 

a snippet view.py

from django.core.mail import send_mail django.core.mail import emailmessage  def search(request):      '''     other bits of code     '''              send_mail("subject goes here", "text goes here", 'noreply@hotmail.com', ['myhotmailaccount@hotmail.com'], fail_silently=true)         #msg = emailmessage("subject goes here", "text goes here", 'noreply@hotmail.com', ['myhotmailaccount@hotmail.com'])         #msg.send()         #return httpresponse('%s'%res) 

the problem is: [errno 60] operation timed out. reason don't quite know what, email not sent. going wrong?

the settings wrongly configured hotmail account, testing for. instead of:

email_host = 'smtp.live.com'  email_port = 465 

it should be:

email_host = 'smtp-mail.outlook.com' email_port = 25 

and tweeked line (although makes no difference):

send_mail("hi there", "text goes here", settings.email_host_user, ['myhotmailaddress@hotmail.com'], fail_silently=true) 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -