0

So I'm using Flask for a website and I'm using the extension Flask Mail to send emails for me. Unfortunately, my email server doesn't support CRAM_MD5 (for a valid reason) so when smtplib.py (Python system library file) reaches the line that is:

preferred_auths = [AUTH_CRAM_MD5, AUTH_PLAIN, AUTH_LOGIN]

it uses CRAM, and fails because of an authentication error. On my development server, I just edited the file and switch the order of PLAIN and CRAM and faced no problems. My system admin doesn't want to make this change every time he does a server build if he can help it so I was wondering if there was a way I could overwrite that system library variable from my Flask application? My Flask application is a little large so if there is a way to do this, I can post a structure of my application. I mostly want to know if it is possible to overwrite variables in system libraries and if so, the standard procedure for doing so. Thanks!

chelseanderby
  • 39
  • 1
  • 6
  • I suspect that something else is causing the problem. If `AUTH_CRAM_MD5` fails, `SMTP.login` should move on to the next item in the list, `AUTH_PLAIN`. You may need to share the configuration you use for Flask-Mail (with sensitive information replaced with dummy values). – dirn Jul 01 '16 at 18:49
  • Interesting... I played around with my configuration a little but my email server was a little picky and these were the only settings that seemed to worked. I could have easily missed some things or not have them posted here but I think this is it. In my config file, It's essentially something along the lines of - MAIL_SERVER = 'smtp.hostname.com' MAIL_PORT = 587 MAIL_USE_TLS = True MAIL_USERNAME = 'tom' MAIL_PASSWORD = 'apassword' MAIL_SUBJECT_PREFIX = '' MAIL_SENDER = 'my@email.com' - with the security info abstracted outside the script, of course. – chelseanderby Jul 01 '16 at 20:00

0 Answers0