kootenpv / yagmail

Send email in Python conveniently for gmail using yagmail
MIT License
2.66k stars 265 forks source link

SSL Context? #120

Open Lvl4Sword opened 6 years ago

Lvl4Sword commented 6 years ago

Going through the docs, I didn't notice anything to do with SSL Context.

Are any of these set anywhere?

kootenpv commented 5 years ago

I am not sure - the only thing I am relying on is using the right port and using SMTP_SSL from smtplib. I think you cannot tweak much yourself (as this also targets gmail first of all), but it should use encrypted communication with gmail when using smtp_ssl=True (the default).

Wongboo commented 2 years ago

With python 3.10 launching, the need to change context rises up(since default context is much more strict, so you need to change it)

kootenpv commented 2 years ago

With python 3.10 launching, the need to change context rises up(since default context is much more strict, so you need to change it)

Do you have a code example for it?

Wongboo commented 2 years ago
import ssl
import smtplib

port = 465
smtp_server = ** # server
login = ** # your login generated by Mailtrap
password = ** # your password generated by Mailtrap
ctx = ssl.create_default_context()
ctx.set_ciphers('ALL:@SECLEVEL=2')
s = smtplib.SMTP_SSL(smtp_server, port, context=ctx)
s.login(login, password)

This is a smtplib example, the reason to require a new context is that a lot of mail server doesn't have a very secure cipher that python 3.10 requires

Lvl4Sword commented 2 years ago

I had completely forgotten about this issue, which was from 3 years ago..

I normally will just use something like prep_mail and mail_this from my LockMsg script -- https://github.com/Lvl4Sword/LockMsg/ -- if I need e-mail in Python. Either that or Sendgrid, Mailchimp, etc.