send_mail()未发送到相关电子邮件地址的电子邮件

时间:2019-11-07 11:24:34

标签: python sendmail

我正在尝试向列表中的每个电子邮件地址发送个性化电子邮件。打印语句表明该消息是正确组成的。问题是我多次收到同一封电子邮件,而不是多封电子邮件。我正在使用基于文件的emailbackend。这是我的代码

def send_lst():
    for row in df.itertuples(index=True, name='Pandas'):
        name = getattr(row, "full_name")
        email = getattr(row, "email_address")
        action = getattr(row, "action")
        device = getattr(row, "device_name")
        barcode = getattr(row, "barcode")
        instance = getattr(row, "instanceID")
        emailed = getattr(row, "emailed")
        date = getattr(row, "receipt_date")

        message = 'Dear {}, \nYou have been recorded as {} a {} with barcode {} on {}. \nIf this information is incorrect, please contact the Digital Team.'.format(name, action, device, barcode, date)
        send_mail('Asset tracker confirmation',
                  message,
                  'me@company.org',
                  [email],
                  fail_silently=False)
        return ()

    print(message)```

0 个答案:

没有答案