Fixed Mails showning in SPAM

This commit is contained in:
mananapr 2017-04-11 16:06:29 +05:30
parent 18267f1f63
commit 09b47a2ec0
1 changed files with 11 additions and 6 deletions

View File

@ -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)