Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions MAIL Sender/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
This is the sample content of sample mail getting send using python file.
</body>
</html>
22 changes: 22 additions & 0 deletions MAIL Sender/send_mail.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

""" Everything with $ need to be replaced"""

import smtplib
from email.message import EmailMessage
from string import Template
from pathlib import Path

html_file = Template(Path('index.html').read_text()) #index.html is a file we are using to make our mail specific
email = EmailMessage()
email['from'] = '$YOUR_NAME'
email['to'] = '$EMAIL_OF_RECEIVER'
email['subject'] = '$SUBJECT'

email.set_content(html_file.substitute(name ='$NAME_HERE'), 'html')

with smtplib.SMTP(host='smtp.gmail.com', port=587) as smtp:
smtp.ehlo()
smtp.starttls()
smtp.login('$YOUR_GMAIL_HERE', '$PASSWORD_HERE')
smtp.send_message(email)
print('Mail sended')