notebook
This commit is contained in:
29
Emailtest/10 EmailTest.py
Normal file
29
Emailtest/10 EmailTest.py
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import smtplib
|
||||
from email.message import EmailMessage
|
||||
|
||||
# ========= CONFIG =========
|
||||
SMTP_SERVER = "smtp.office365.com"
|
||||
SMTP_PORT = 587
|
||||
EMAIL_FROM = "ordinace@buzalkova.cz"
|
||||
EMAIL_TO = "vladimir.buzalka@buzalka.cz"
|
||||
SMTP_USER = "ordinace@buzalkova.cz"
|
||||
SMTP_PASS = "********" # <- your Office365 APP PASSWORD (see note below)
|
||||
# ==========================
|
||||
|
||||
# Create the email
|
||||
msg = EmailMessage()
|
||||
msg["Subject"] = "Test zpráva z Pythonu"
|
||||
msg["From"] = EMAIL_FROM
|
||||
msg["To"] = EMAIL_TO
|
||||
msg.set_content("Dobrý den,\n\ntoto je testovací e-mail odeslaný z Python skriptu.\n\n--\nOrdinace MUDr. Buzalková")
|
||||
|
||||
# Send the email
|
||||
with smtplib.SMTP(SMTP_SERVER, SMTP_PORT) as server:
|
||||
server.starttls() # enable TLS encryption
|
||||
server.login(SMTP_USER, SMTP_PASS)
|
||||
server.send_message(msg)
|
||||
|
||||
print("✅ E-mail byl úspěšně odeslán!")
|
||||
Reference in New Issue
Block a user