kootenpv / yagmail

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

Sending smtp with starttls #254

Open augustasvol opened 1 year ago

augustasvol commented 1 year ago

It works perfectly when sending emails with SSL, however, when I try to send with STARTTLS it does not work and the docs do not state how to do it.

It would be great if the docs could be updated on SMTP sending because yagmail is the best way to send emails in python.

kootenpv commented 1 year ago

Were you able to ultimately make it work? I do remember looking at starttls at some point... But don't remember details

augustasvol commented 1 year ago

No, I haven't. I really don't know what to do to enable the starttls.

I did: help(yagmail.SMTP) Got:

SMTP(user=None, password=None, host='smtp.gmail.com', port=None, smtp_startt
ls=None, smtp_ssl=True, smtp_set_debuglevel=0, smtp_skip_login=False, encoding='
utf-8', oauth2_file=None, soft_email_validation=True, dkim=None, **kwargs)

So there is an option to do something with smtp_starttls, however I have no idea what to pass to it. Should I pass something from the smtplib?

kootenpv commented 1 year ago

It's used like this:

def starttls(self):
    if self.smtp_starttls is None:
        return False if self.ssl else True
    return self.smtp_starttls

so basically if you don't provide anything and ssl=True then it is False

you can explicitly pass False or True yourself

augustasvol commented 1 year ago

I see, thank you.

I'll try it and report back if this works.