Setting MAIL_USE_SSL or MAIL_USE_TLS to non-boolean type
Closed this issue · 1 comments
Hi,
I came across an issue when I accidentally set MAIL_USE_SSL and MAIL_USE_TLS to strings as opposed to booleans ( I had naively gathered all my Flask-Mail settings from the environment variables). Anyways, long story short, I was getting the following error every time I attempted to send an email: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1123).
The reason was that I had MAIL_USE_TLS set to "True" and MAIL_USE_SSL set to "False", instead of True and False respectively, and I also set MAIL_PORT = 587. So when the Connection object made a call to configure_host() and it was checked if self.mail.use_ssl
, host was set to smtplib.SMTP_SSL(self.mail.host, self.mail.port)
, where self.mail.port was set to 587.
Anyways, perhaps there should be some type verification for the configuration variables upon initializing the Mail object? Or, maybe change the conditional in Connection.configure_host() to if self.mail.use_ssl == True:
and if self.mail.use_tls == True:
?
In general, Python does not do this type of input type checking for all arguments.