sending email reminders by company
This commit is contained in:
35
smtp-TLS-office365-dumas.py
Normal file
35
smtp-TLS-office365-dumas.py
Normal file
@@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python3
|
||||
import smtplib
|
||||
import ssl
|
||||
|
||||
# Fabrication du corps du email_passwordMessage
|
||||
sender = "peinture@entreprise-dumas.com"
|
||||
receiver = "phuoc@caotek.fr"
|
||||
message = """\
|
||||
Subject: Test d'envoi d'un message en TLS
|
||||
|
||||
Voici le contenu du message. Phuoc Cao"""
|
||||
|
||||
# Create a secure SSL context
|
||||
context = ssl.create_default_context()
|
||||
smtp_server = "smtp.office365.com"
|
||||
smtp_port = 587 # For TLS
|
||||
smtp_user = "peinture-dumas@entreprise-dumas.com"
|
||||
smtp_pass = "Nar50611"
|
||||
|
||||
# Try to log in to server and send email
|
||||
try:
|
||||
server = smtplib.SMTP(smtp_server,smtp_port)
|
||||
# server.ehlo() # Can be omitted
|
||||
server.starttls(context=context) # Secure the connection
|
||||
# server.ehlo() # Can be omitted
|
||||
server.login(smtp_user, smtp_pass)
|
||||
# envoyer l'email
|
||||
server.sendmail(sender, receiver, message)
|
||||
print("sendmail -> OK")
|
||||
|
||||
except Exception as e:
|
||||
# Print any error messages to stdout
|
||||
print(e)
|
||||
finally:
|
||||
server.quit()
|
||||
Reference in New Issue
Block a user