示例#1
0
    def post(self):
        login = self.get_argument("login", None)
        password = self.get_argument("password", None)

        invite_code = self.get_argument("invite_code", None)
        email = self.get_argument("email", None)
        name = self.get_argument("name", None)
        password1 = self.get_argument("password1", None)
        password2 = self.get_argument("password2", None)

        if login and password:
            user_id, user = nomagic.auth.check_user(login, password)
            if user_id:
                self.set_secure_cookie(
                    "user", tornado.escape.json_encode({"user_id": user_id}))
                self.redirect("/?status=login")
                return

        elif email and name and password1 and password2 and password1 == password2 and invite_code:
            invited = conn.get("SELECT * FROM invite WHERE code = %s",
                               invite_code)
            if not invited:
                self.redirect("/login?status=need_invite_code")
                return

            data = {"email": email, "name": name, "password": password1}
            try:
                user_id, user = nomagic.auth.create_user(data)

                self.set_secure_cookie(
                    "user", tornado.escape.json_encode({"user_id": user_id}))

                email_verify_code = ''.join(
                    random.choice(string.digits + string.letters)
                    for x in range(14))
                result = nomagic.auth.update_user(
                    user_id, {
                        "email_verified": False,
                        "email_verify_code": email_verify_code
                    })

                #send verify email here
                msg = EmailMessage()
                msg.subject = "Confirm Email from Pythonic Info"
                msg.bodyText = "http://pythonic.info/verify_email?user_id=%s&verify_code=%s" % (
                    user_id, email_verify_code)
                self.send("*****@*****.**", str(email), msg)
                print "url:", msg.bodyText

                self.redirect("/?status=created")
                return
            except:
                pass

        self.redirect("/login?status=error")
示例#2
0
    def post(self):
        email = self.get_argument("email")
        token = nomagic.email_invite(email)
        print token

        #send email
        msg = EmailMessage()
        msg.subject = u"Confirm email from Pythonic Info"
        msg.bodyText= u"http://pythonic.info/verify_email?token=%s" % token
        self.send("*****@*****.**", email, msg)
        self.finish({})
def sendMail(body):

    AccessKeyID = 'AKIAIEE65XFVJKO6HIJA'
    SecretAccessKey = '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'

    amazonSes = AmazonSES(AccessKeyID, SecretAccessKey)

    message = EmailMessage()
    message.subject = 'House hunt'
    message.bodyText = body

    result = amazonSes.sendEmail('*****@*****.**', '*****@*****.**', message)
示例#4
0
    def post(self):
        login = self.get_argument("login", None)
        password = self.get_argument("password", None)

        invite_code = self.get_argument("invite_code", None)
        email = self.get_argument("email", None)
        name = self.get_argument("name", None)
        password1 = self.get_argument("password1", None)
        password2 = self.get_argument("password2", None)

        if login and password:
            user_id, user = nomagic.auth.check_user(login, password)
            if user_id:
                self.set_secure_cookie("user", tornado.escape.json_encode({"user_id": user_id}))
                self.redirect("/?status=login")
                return

        elif email and name and password1 and password2 and password1 == password2 and invite_code:
            invited = conn.get("SELECT * FROM invite WHERE code = %s", invite_code)
            if not invited:
                self.redirect("/login?status=need_invite_code")
                return

            data = {"email": email, "name": name, "password": password1}
            try:
                user_id, user = nomagic.auth.create_user(data)

                self.set_secure_cookie("user", tornado.escape.json_encode({"user_id": user_id}))

                email_verify_code = ''.join(random.choice(string.digits+string.letters) for x in range(14))
                result = nomagic.auth.update_user(user_id, {"email_verified": False, "email_verify_code": email_verify_code})

                #send verify email here
                msg = EmailMessage()
                msg.subject = "Confirm Email from Pythonic Info"
                msg.bodyText = "http://pythonic.info/verify_email?user_id=%s&verify_code=%s" % (user_id, email_verify_code)
                self.send("*****@*****.**", str(email), msg)
                print "url:", msg.bodyText

                self.redirect("/?status=created")
                return
            except:
                pass

        self.redirect("/login?status=error")
示例#5
0
from amazon_ses import AmazonSES, EmailMessage
import datetime
AccessKeyID = 'AKIAIEE65XFVJKO6HIJA'
SecretAccessKey = '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'

amazonSes = AmazonSES(AccessKeyID, SecretAccessKey)

message = EmailMessage()
message.subject = 'Hello from Amazon SES! Test subject'
message.bodyText = 'This is body text of test message.'

val=datetime.date.today()
print val,type(val)

#result = amazonSes.sendEmail('*****@*****.**', '*****@*****.**', message)    
print result.requestId
print result.messageId