def __init__(self, user, pw, admin, shopper=[]):
     self.id = "Mail Robot"
     self.admin = admin
     self.shopper = shopper
     self.datapath = sys.argv[0].rsplit("/", 1)[0]
     print "Datapath set to:", self.datapath
     self.memory = memory.Memory(self.datapath, "email_server")
     self.eh = EmailHelper()
     self.eh.setLoginData(user, pw)
     self.cart_send = False
Esempio n. 2
0
def newAdmin():
    if not request.json or not 'email' in request.json:
        abort(400)

    email = request.json['email']
    validation_key = uuid.uuid4().hex

    with db_session:
        pendingUser = get(u for u in PendingUser if u.email == email)
        if pendingUser is None:
            pendingUser = PendingUser(email=email,
                                      validation_key=validation_key)
            commit()

    EmailHelper.send_invite(email, current_app.config)
    return "success"
Esempio n. 3
0
def register():
    if not request.json or not 'email' in request.json or not 'password' in request.json:
        abort(400)

    email = request.json['email']
    password = request.json['password']
    with db_session:
        pendingUser = get(u for u in PendingUser if u.email == email)
        if pendingUser is None:
            abort(400)
        newUser = User(email=email, password="******", email_verified=False)
        newUser.set_password(password)
        commit()

    EmailHelper.send_verification(email, pendingUser.validation_key,
                                  current_app.config)
    return "success"
class EmailScheduleServer:
    def __init__(self, user, pw, admin, shopper=[]):
        self.id = "Mail Robot"
        self.admin = admin
        self.shopper = shopper
        self.datapath = sys.argv[0].rsplit("/", 1)[0]
        print "Datapath set to:", self.datapath
        self.memory = memory.Memory(self.datapath, "email_server")
        self.eh = EmailHelper()
        self.eh.setLoginData(user, pw)
        self.cart_send = False

    def saveMail(self, sender, body, date, sender_name):
        self.memory.insertData(date, [sender, body, sender_name])

    def checkForNewJobs(self):
        msgs = self.eh.fetchEmails(True)
        for msg in msgs:  # [from,subject,message body,date,attachmentname,sender_name]

            try:
                if msg[1] == "**newrobotjob":
                    if not self.memory.hasKey(msg[3]):
                        content = self.extractDataFromBody(msg[2])
                        if not self.eh.isAddressValid(content["receiver"]):
                            failmsg = ["FAIL: Job not added", "Invalid recepient address provided. Job skipped"]
                            self.sendFail(msg[0], *failmsg)
                        if content["message"] == "":
                            failmsg = ["FAIL: Job not added", "Message body seems to be empty"]
                            self.sendFail(msg[0], *failmsg)
                        else:  # everything seems fine
                            content["attachment"] = msg[4]
                            self.saveMail(msg[0], content, msg[3], msg[5])
                            self.sendConfirmation(msg[3])
                elif msg[1] == "**shopping":
                    self.updateShoppingCart(msg[0], msg[2])
                elif msg[1] == "**mask":
                    self.sendMask(msg[0])
                else:  # check for keywords in current jobs and send response
                    key = self.validKeywordFound(msg)
                    if not key is None:
                        data = self.memory.getData(key)
                        self.eh.sendMail(msg[5], data[0], data[1]["subject"], msg[2])
                        self.memory.removeData(key)
                    else:
                        print "unknown email received"
                        print "transfering to admin"
                        self.transferMessageToAdmin(msg)
                        print "msg", msg
                self.eh.deleteMailByDate(msg[3])
            except Exception, e:
                print "evaluating new email job failed!"
                print e
Esempio n. 5
0
def main(site, src_user, src_pwd, dest):
    # grab the page
    uf = urllib.request.urlopen(site)
    html = uf.read()

    # parse the page for desired data
    soup = BeautifulSoup(html, "html.parser")
    rate_info = grab_mortgage_rate(soup)
    print(rate_info)

    # create message to send (empty body)
    msg = EmailMessage()
    msg['Subject'] = rate_info
    msg['From'] = src_user
    msg['To'] = dest

    # send message in e-mail to self
    mail_butler = EmailHelper()
    mail_butler.login(src_user, src_pwd)
    mail_butler.send(src_user, dest, msg)
    mail_butler.close()
Esempio n. 6
0
    # another instance is running
    print('Alredy running!')
    sys.exit(1)

PREVIEW_URL = "https://ethwallpaper.co/preview/"
IMAGES_PATH = "../backend/static/wallpapers/"
images = []
dir_path = os.path.dirname(os.path.realpath(__file__))

config = ConfigParser()
config_path = os.path.join(dir_path, '../config.ini')
config_path = os.path.normpath(config_path)
config.read(config_path)
pgconfig = {}

email_client = EmailHelper(config['sendgrid']['api_key'])

for param in config.items('postgresql'):
    pgconfig[param[0]] = param[1]

# Connect to an existing database
conn = psycopg2.connect(**pgconfig)
cur = conn.cursor()

cur.execute(
    "SELECT id, ext, logo_size, author_email FROM api_wallpaper WHERE status='Pending';"
)

images_done = []

while True: