forked from lemontang93/news_feed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_bot.py
40 lines (25 loc) · 764 Bytes
/
mail_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# --*-- coding: utf-8 --*--
import os
import sys
BASE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
sys.path.append(BASE_DIR)
import time
from utils.send_email import send_mail
from config import SEND_MAIL_INTERVAL
from db_access import get_users
from utils.blacklist import blacklist_email
def mail_bot():
while True:
user_list = get_users()
addr_list = []
for u in user_list:
if u.email not in blacklist_email:
addr_list.append(u.email)
for to in addr_list:
try:
send_mail(to)
except Exception as e:
print(str(e))
time.sleep(60 * 60 * SEND_MAIL_INTERVAL)
if __name__ == '__main__':
mail_bot()