-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingTwilio.py
57 lines (48 loc) · 1.31 KB
/
SettingTwilio.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client
from FetchMail import Get_Mail
import time
import schedule
# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
SentFrom = os.environ['TWILIO_FROM_NUM']
SentTo = os.environ['TWILIO_TO_NUM']
def Send_msg(text):
client = Client(account_sid, auth_token)
message = client.messages.create(
body=text,
from_='whatsapp:'+SentFrom,
to='whatsapp:'+SentTo
)
# print(message.sid)
def sendOnebyOne():
# Send_msg("mail")
MailList = Get_Mail()
print("\nIN\n")
for mail in MailList:
# time.sleep(1)
print("waiting\n")
Send_msg(mail)
print("\n---SENT--\n")
# print(mail,"\n")
time.sleep(1)
def Scheduler():
schedule.every(10).minutes.do(sendOnebyOne)
while True:
# Checks whether a scheduled task
# is pending to run or not
schedule.run_pending()
time.sleep(1)
Scheduler()
# if __name__ == '__main__':
# # Send_msg("mail")
# for mail in MailList:
# # print(mail)
# # Send_msg("mail")
# time.sleep(1)
# Send_msg(mail)
# # print("SENT\n")
# # time.sleep(1)