Skip to content

Instantly share code, notes, and snippets.

@benjaminguinaudeau
Last active August 18, 2020 09:36
Show Gist options
  • Save benjaminguinaudeau/9810efef3179e12474eda01d81b380c5 to your computer and use it in GitHub Desktop.
Save benjaminguinaudeau/9810efef3179e12474eda01d81b380c5 to your computer and use it in GitHub Desktop.
Send email with uni konstanz account
#!/usr/bin/env python
import smtplib
from email.mime.text import MIMEText
def send_mail_starttls(sender = '', to = '', pwd = '', subject = '', msg = ''):
recipients = [to, sender]
msg = MIMEText(msg)
msg['Subject'] = subject
msg['From'] = sender
msg['To'] = to
with smtplib.SMTP("smtp.uni-konstanz.de", 587) as server:
server.starttls() # Secure the connection
server.login(sender, pwd)
server.sendmail(sender, recipients, msg.as_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment