From 09b47a2ec01687cdf96e22e54450ae59a76180a9 Mon Sep 17 00:00:00 2001 From: mananapr Date: Tue, 11 Apr 2017 16:06:29 +0530 Subject: [PATCH] Fixed Mails showning in SPAM --- lainchan.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lainchan.py b/lainchan.py index 06f5a49..4113ba7 100644 --- a/lainchan.py +++ b/lainchan.py @@ -13,8 +13,8 @@ import smtplib import getpass from datetime import datetime -EMAIL_SOURCE = 'sender_email_id_goes_here' -EMAIL_TARGET = 'target_email_id_goes_here' +EMAIL_SOURCE = 'mananapr@gmail.com' +EMAIL_TARGET = 'ms704@snu.edu.in' PASS = getpass.getpass("Enter Password for %s: " %(EMAIL_SOURCE)) # Function to send URL of thread in mail to EMAIL_TARGET @@ -23,14 +23,19 @@ def send_mail(url, diff): server.ehlo() server.starttls() server.login(EMAIL_SOURCE, PASS) - msg = str(diff) + ' new replies at ' + url + msg = "\r\n".join([ + "From: " + EMAIL_SOURCE, + "To: " + EMAIL_TARGET, + "Subject: New Messages at Lainchan", + "", + str(diff) + " new post(s) at " + str(url) + ]) server.sendmail(EMAIL_SOURCE, EMAIL_TARGET, msg) server.quit() # Dictionary of URLs to watch for with their posts count. urls = { - 'https://lainchan.org/lam/res/22622.html' : 0, - 'https://lainchan.org/lam/res/21073.html' : 0, + 'https://lainchan.org/tech/res/35471.html' : 0, 'https://lainchan.org/lam/res/17682.html' : 0 } @@ -67,7 +72,7 @@ while True: if count > c : diff = count - c; print("\n%d new post(s)" %(diff)) - print("Sending Mail...") + print("Sending Mail...\n") urls[url] = count send_mail(url, diff)