发送订阅电子邮件,验证用户是否在“确认订阅”中单击,并在单击时发送电子邮件。。。同一功能

2024-09-30 01:36:35 发布

您现在位置: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)   

我试图用最好的方式解释这个问题,但可能有点困惑,如果你不明白请说。你知道吗


Tags: thetoingtmessagegettopichere

热门问题