Пример #1
0
def check_email():

    check_read_mails()

    user = "******"  #enter your gmail hosted email address
    host = "imap.gmail.com"
    port = 993
    password = '******'  #replace with your email address password

    check_read_mails()

    M = imaplib.IMAP4_SSL(host, port)
    M.login(user, password)
    M.select(readonly=True)
    typ, data = M.search(None, '(UNSEEN SUBJECT )')

    if data[0]:
        emails = data[0].split()
        emails.reverse()

        f = open('readmails.txt')
        readmails = f.read()
        f.close()

        for num in emails:
            if num not in set(readmails.split()):
                typ, data = M.fetch(num, "(RFC822)")
                from_addr = data[0][1].split("From:")[1].split(
                    "\n")[0].strip().split('<')[0].strip()
                print "From:", from_addr
                sub = data[0][1].split("Subject:")[1].split("\n")[0].strip()
                print "Subject:", sub
                message = from_addr + '-' + sub
                f = open('readmails.txt', 'a')
                f.write(' ' + num + ' ')
                send_sms(
                    '8888888888', '********', '7777777777', message
                )  #send_sms('160by2 login','160by2 password','destination number','your message')
                time.sleep(0.2)
    M.logout()
Пример #2
0
def check_email():

    check_read_mails()

    user = "******" #enter your gmail hosted email address
    host = "imap.gmail.com"
    port = 993
    password = '******' #replace with your email address password

    check_read_mails()
        
    M = imaplib.IMAP4_SSL(host, port)
    M.login(user,password)
    M.select(readonly=True)
    typ, data = M.search(None, '(UNSEEN SUBJECT )')

    if data[0]:
        emails = data[0].split()
        emails.reverse()

        f = open('readmails.txt')
        readmails = f.read()
        f.close()    

        for num in emails:
            if num not in set(readmails.split()):
                typ, data = M.fetch(num,"(RFC822)")
                from_addr = data[0][1].split("From:")[1].split("\n")[0].strip().split('<')[0].strip()
                print "From:", from_addr
                sub = data[0][1].split("Subject:")[1].split("\n")[0].strip()
                print "Subject:", sub
                message = from_addr + '-' + sub
                f = open('readmails.txt','a')
                f.write(' '+num+' ')
                send_sms('8888888888','********','7777777777',message) #send_sms('160by2 login','160by2 password','destination number','your message')
                time.sleep(0.2)
    M.logout()
Пример #3
0
def submitData(request):
    if request.method == 'POST':
        print("Ajax request recieved")
        formData = json.loads(request.POST['formData'])
        print(formData)
        try:
            firstName = formData['firstName']
            lastName = formData['lastName']
            address = formData['address']
            contact = formData['contact']
            items = formData['items']
            slot_id = int(formData['slot_id'])
        except Exception as e:
            print(e)
            print("Invalid Data Received")

        # print('Slot_id : ', slot_id)

        slot = VolunteerSlot.objects.get(slot_id=slot_id)
        req = DonationRequest(slot=slot,
                              first_name=firstName,
                              last_name=lastName,
                              address=address,
                              phone_number=contact,
                              items=items)

        print(f"Sending SMS to {slot.phone_number}")
        slot_phonenumber = slot.phone_number
        slot_message = f"{firstName} {lastName} registered for slot on {slot.start_time}. Pickup adress: {address}, Donor Phone number: {contact}"
        if send_sms(slot_phonenumber, slot_message):
            print("SMS sent successfully")
            req.save()
            print("Request saved")

        else:
            print("SMS sending unsucessful")
            return bad_request('Request unsucessful, Please Try Again')

        response = JsonResponse({
            'formData': formData,
            'message': "Form submitted successfully",
            'redirect': '/success/'
        })

        return response
Пример #4
0
#!/usr/bin/python
# -*- coding: utf-8 -*- 
import hpilo
import sendsms
import os,time

# ILOGB851486EN
mysrv = hpilo.Ilo('192.168.1.2',login='******',password='******',timeout=60,port=443) # авторизуемся на сервере iLo

sendsms.send_sms('+380501234567','Internet store http://tekhnika.ua is down!')                 # Шлем себе СМС
os.system('sudo /usr/bin/monit unmonitor "tekhnika.ua"')                                       # отключаем мониторинг сайта

mysrv.reset_server()                     # Power cycle the server - пытаемся перегрузить сервер

time.sleep(6*60) 				       # выжидаем 6 минут
os.system('sudo /usr/bin/monit monitor "tekhnika.ua"') # возобновляем мониторинг сайта
Пример #5
0
import sendsms

FIREBASE_URL = "https://mhacks9-fead9.firebaseio.com/"
fb_auth = firebase.FirebaseAuthentication("wdeBNz2sf00t3l3UIp53Hv3AzLR3jTU7VMHCUGGS", '*****@*****.**', debug=True, extra=None)

fb = firebase.FirebaseApplication(FIREBASE_URL, fb_auth) # Create a reference to the Firebase Application
users = fb.get('/users', None) # Get  data from firebase


while True:
	for user in users: 

		print user
		for events in user["Events"]:

			print events
			serverDate = events["date"] + " " + events["time"]
			datetime_sys = now.strftime("%m-%d-%Y %H:%M")

			if datetime_sys <= serverDate:
				song = events["song"]
				phone = user["phone"]
				name = events["name"]
				time = events["time"]
				message = "Hey you have an appointment today named: " + name + "at" + time

				sendsms.send_sms(phone, message)


print result