Skip to content

Commit 62b175c

Browse files
committed
update sending emails tutorial
1 parent 4a88681 commit 62b175c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

general/email-sender/email_sender.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
def send_mail(email, password, FROM, TO, msg):
77
# initialize the SMTP server
8-
server = smtplib.SMTP("smtp.gmail.com", 587)
8+
# in our case it's for Microsoft365, Outlook, Hotmail, and live.com
9+
server = smtplib.SMTP(host="smtp.office365.com", port=587)
910
# connect to the SMTP server as TLS mode (secure) and send EHLO
1011
server.starttls()
1112
# login to the account using the credentials
@@ -20,7 +21,7 @@ def send_mail(email, password, FROM, TO, msg):
2021
password = "password"
2122

2223
# the sender's email
23-
FROM = "email@example.com"
24+
FROM = email
2425
# the receiver's email
2526
2627
# the subject of the email (subject)

general/email-sender/email_sender_with_attachments.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515

1616
def send_mail(email, password, FROM, TO, msg):
17-
# initialize the SMTP server
18-
server = smtplib.SMTP("smtp.gmail.com", 587)
17+
# in our case it's for Microsoft365, Outlook, Hotmail, and live.com
18+
server = smtplib.SMTP(host="smtp.office365.com", port=587)
1919
# connect to the SMTP server as TLS mode (secure) and send EHLO
2020
server.starttls()
2121
# login to the account using the credentials
@@ -30,7 +30,7 @@ def send_mail(email, password, FROM, TO, msg):
3030
password = "password"
3131

3232
# the sender's email
33-
FROM = "email@example.com"
33+
FROM = email
3434
# the receiver's email
3535
3636
# the subject of the email (subject)

0 commit comments

Comments
 (0)