电子邮件发送到错误的我们

2024-06-16 14:27:01 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个功能,重新安排捐助者的日期为他们的捐款,由于恶劣的天气。用户可以进行大规模重新调度。如果捐赠者有一封电子邮件,它会向他们发送一封电子邮件,允许他们“确认”、“重新安排”或“取消”带有UUID的链接。你知道吗

在测试时,我遇到了一个非常奇怪的问题。我重新安排了5个捐赠者,都是邮件。你知道吗

austin@gmail.com
another@email.com
metkil@yahoo.com
austin@outlook.com
bbbbb@gmail.com

每封邮件都以“你好捐赠者姓名”开头@雅虎网站电子邮件,不管我把它放在什么顺序,得到相同的电子邮件邮箱:austin@gmail.com一个。只有@yahoo电子邮件我才有这个问题。我打印出来的电子邮件正文之前,它被发出和正文看起来正确,但一旦收到电子邮件,它是错误的,并采取了第一捐助者的内容。你知道吗

我将发送电子邮件的过程放在for rescheduled_donor in donors_with_emails循环中,并通过sendgrid作为我的smtp服务一次发送一封。你知道吗

  for rescheduled_donor in donors_with_emails

      recipient = rescheduled_donor.email    

      #..........

      body = template.render(context)   
      print 'Recipient: {0}'.format(recipient)     
      email.to = [recipient]                       
      email.body = body                            
      email.attach_alternative(body, "text/html")  
      email.send()                                 
      print email.body        

电子邮件的初始化在我的方法的顶部,在for循环之外

 email = EmailMultiAlternatives()                           
 email.subject = email_script.subject                       
 email.from_email = DEFAULT_FROM_EMAIL                      
 template = get_template('email/email.html')   

我一辈子都搞不懂为什么只有这一封邮件没有得到正确的内容,反而收到了第一批捐赠者。你知道吗


Tags: comfor电子邮件email邮件bodytemplateyahoo