Skip to content

Commit d3f7544

Browse files
committed
Email API Added
1 parent 6d697f2 commit d3f7544

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

Sending-Emails/Readme.md

Whitespace-only changes.

Sending-Emails/code.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
###### Notice ######
2+
3+
# before sending email you have to enable your less secure apps access in your sending mail ([email protected])
4+
5+
import smtplib
6+
from email.message import EmailMessage
7+
8+
EMAIL_ADDRESS = "[email protected]" # your email-id goes here
9+
EMAIL_PASSWORD = "xyz" # your password goes here
10+
11+
msg = EmailMessage()
12+
msg['Subject'] = 'this is subject'
13+
msg['From'] = EMAIL_ADDRESS
14+
msg['To'] = EMAIL_ADDRESS
15+
16+
msg.set_content('Content area')
17+
18+
msg.add_alternative("""\
19+
<html>
20+
<body>
21+
<h1>Your HTML CONTENT GOES HERE </h1>
22+
</body>
23+
</html>
24+
""", subtype='html')
25+
26+
with open('testing.txt', 'rb') as f: # your filename will go here
27+
file_data = f.read()
28+
file_name = f.name
29+
30+
msg.add_attachment(file_data, maintype='application', subtype='octet-stream', filename=file_name)
31+
32+
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
33+
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
34+
35+
smtp.send_message(msg)

Sending-Emails/testing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is for testing purpose

0 commit comments

Comments
 (0)