发送订阅电子邮件,验证用户是否单击了“确认订阅”,如果他点击了同一功能,则发送电子邮件

时间:2015-04-02 13:12:46

标签: python

我在下面有这个功能,在这个功能中我试着做4件事:

- >创建一个主题

- >发送确认订阅电子邮件

- >验证用户是否单击了“确认订阅”

- >如果用户在“确认订阅”中单击,则发送电子邮件

问题在于,我总是收到消息“待确认,请在您的电子邮件中确认订阅,然后我们会向您发送电子邮件......”。

即使我确认订阅我总是收到此消息,我需要再次执行代码才能发送电子邮件。

但我的想法是发送电子邮件而不再执行代码,所以我有一个while循环来检查订阅状态,当它与“PendingConfirmation”不同时我想发送这行的电子邮件:

publication = c.publish(topicArnResult, message, subject=message_subject

def createTopicSendConfirmSubscriptionSendEmail(msg):

    # here i get topic name and email from my msg dictonary
    topicname = msg['topico']

    emailaddress = msg['email']

    # I create a topic
    topicarn = c.create_topic(topicname)
    # And send a "Subscription Confirmation" email 
    # so the user can click in "Confirm Subscription" to start receive emails
    subscription = c.subscribe(topicArnResult, "email", emailaddress)

    # And then I want to send a email to the user, 
    # but only when he clicks in "Confirm subscription" link 
    # in the email sent in previous line


    getSubscriptions = c.get_all_subscriptions_by_topic(topicArn)
    # here i get the subscription email status
    getSubscriptionEmailStatus = getSubscriptions[...] 
    message = "test message"
    message_subject = "test subject"

    # while SubscriptionEmailStatus is "PendingConfirmation" I wan to show a message
    while getSubscriptionEmailStatus == "PendingConfirmation":      
        raw_input("Pending Confirmation, 
        please confirm subscription in your email
        and then we will sent you an email...")
        # here i get the subscription email status
        getSubscriptionEmailStatus = getSubscriptions[...] 

    # here I send an email but just when the status != "PendingConfirmation"    
    publication = c.publish(topicArnResult, message, subject=message_subject)   

我试图以最好的方式解释这个问题,但也许有点困惑,如果你不明白请说。

0 个答案:

没有答案