yagmail icon indicating copy to clipboard operation
yagmail copied to clipboard

SSL Context?

Open Lvl4Sword opened this issue 5 years ago • 5 comments

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

Are any of these set anywhere?

  • ssl.CERT_REQUIRED
  • check hostname
  • setting of ciphers for the connection
  • ssl.HAS_SNI
  • ssl.OP_CIPHER_SERVER_PREFERENCE
  • ssl.OP_NO_COMPRESSION
  • https://docs.python.org/3/library/ssl.html#id7
  • ssl.OP_NO_TLSv1
  • ssl.OP_NO_TLSv1_1

Lvl4Sword avatar Jul 29 '18 14:07 Lvl4Sword

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).

kootenpv avatar Apr 23 '19 21:04 kootenpv

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)

Wongboo avatar Nov 23 '21 14:11 Wongboo

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?

kootenpv avatar Nov 23 '21 14:11 kootenpv

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

Wongboo avatar Nov 23 '21 14:11 Wongboo

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.

Lvl4Sword avatar Nov 23 '21 15:11 Lvl4Sword