Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
bulkmailer/mail.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
26 lines (25 sloc)
1.64 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import smtplib | |
import imghdr | |
from email.message import EmailMessage | |
Sender_Email = input('Enter your email id: ') | |
Reciever_Email =input('Enter receivers email id: ') | |
Password = input('Enter your email account password: ') | |
newMessage = EmailMessage() | |
newMessage['Subject'] = "Your Life Is Our Responsibilty" | |
newMessage['From'] = Sender_Email | |
newMessage['To'] = Reciever_Email | |
newMessage.set_content("Thanks for subscribing to great site hospitals. We will be sending you latest published articles on great site hospitals website. /n/n Mail frequency won't be more than twice a month." | |
"We hate spamming as much as you do. To confirm your subscription, please click on the link given below. If clicking does not work, copy paste the URL in browser.If you think this is a mistake, just ignore this email and we would not bother you again." | |
"Note: /n/nThis is notification only email. Please do not reply on this email." | |
"Thanks for subscribing with Great Site Hospitals. Please find an attachment below along with this email /n/n Thanks /n/n Regards /n/n Great Site Hospitals") | |
files = ['Great Site Hospital.pdf'] | |
for file in files: | |
with open(file, 'rb') as f: | |
file_data = f.read() | |
file_name = f.name | |
newMessage.add_attachment(file_data, maintype='application', subtype='octet-stream', filename=file_name) | |
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: | |
smtp.login(Sender_Email, Password) | |
smtp.send_message(newMessage) | |
def bulkemail(): | |
return render_template('mail.html',page=url_for('mail')) |