jertel / elastalert2

ElastAlert 2 is a continuation of the original yelp/elastalert project. Pull requests are appreciated!
https://elastalert2.readthedocs.org
Apache License 2.0
859 stars 277 forks source link

Issue with python 3.12 and starttls #1339

Closed gyterpena closed 7 months ago

gyterpena commented 7 months ago

Hello

I'm getting following error while sending emails, after python upgrade to 3.12

Uncaught exception running rule WebLogs_spike.yaml: SMTP.starttls() got an unexpected keyword argument 'keyfile'

[Traceback (most recent call last):, File "/usr/local/lib/python3.12/site-packages/elastalert/elastalert.py", line 1306, in alert, return self.send_alert(matches, rule, alert_time=alert_time, retried=retried), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^, File "/usr/local/lib/python3.12/site-packages/elastalert/elastalert.py", line 1391, in send_alert, alert.alert(matches), File "/usr/local/lib/python3.12/site-packages/elastalert/alerters/email.py", line 108, in alert, self.smtp.starttls(keyfile=self.smtp_key_file, certfile=self.smtp_cert_file), TypeError: SMTP.starttls() got an unexpected keyword argument 'keyfile'

Looks like 3.12 deprecated keyfile

https://docs.python.org/3/library/smtplib.html#smtplib.SMTP_SSL

nsano-rururu commented 7 months ago

https://stackoverflow.com/questions/77482831/smtp-starttls-got-an-unexpected-keyword-argument-keyfile

nsano-rururu commented 7 months ago

https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.starttls

nsano-rururu commented 7 months ago

Submitting changes You're all welcome to submit a pull request.