Ejemplo n.º 1
0
def lets_reply_now(handler,conn,impersonate):
    server = UnreadEmailReader(username='******',
                            password='******',
                            handler=handler,
                            conn = conn
			)
    data = server.sexydump()
    body = data['body'].split('8870923027')
    number= body[1].split(' ')[0]
    values = handler.execute('SELECT sender FROM actions')
    from_data = values.fetchone()
    #from_data = data['from']
    #print from_data
    #from_data_val = re.search('<(\S+)>',from_data).group(1)
    #print from_data_val
    sg = sendgrid.SendGridClient('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')
    message = sendgrid.Mail()
    message.add_to(from_data[0])
    message.set_subject('Reply from remitbox')
    message.set_text(body[-1])
    #message.set_from('ahua.chaks <*****@*****.**>')
    message.set_from(impersonate)
    status, msg = sg.send(message)
    print status,msg
Ejemplo n.º 2
0
import sqlite3
from unreadEmail import UnreadEmailReader
from reply import *
conn = sqlite3.connect('accounts.db')

class UnreadEmailException(Exception):
    def __init__(self,code,msg):
        self.code = code
        self.msg = msg

    def __str__(self):
        print 'Error {0}: {1}'.format(self.code,self.msg)

handler = conn.cursor()
handler.execute('SELECT * FROM user')
users = handler.fetchall()

for user in users:
    print user
    x = UnreadEmailReader(phone_number=user[2],username=user[3],password=user[4],receipents=user[5],keywords=user[6],handler=handler,conn=conn)
    try:
        x.core()
    except:
        pass
    lets_reply_now(handler,conn,impersonate=user[3])

handler.close()