Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
django mailer从电子邮件地址创建多个db条目_Django_Django Mailer - Fatal编程技术网

django mailer从电子邮件地址创建多个db条目

django mailer从电子邮件地址创建多个db条目,django,django-mailer,Django,Django Mailer,我刚刚实现了django mailer,因为它似乎是从django异步发送邮件的最佳方式 出于某种原因,正在为收件人电子邮件地址的每个字母创建一个db条目,其中“收件人”字段中有一个字母。。。。以下是一个屏幕截图: 为了不显示完整的地址,我删掉了其余的条目,但足以说明所有条目的“收件人”字段加起来就是用户的电子邮件地址。(为了澄清,发送一封电子邮件会为电子邮件地址的每个字母创建一个对象) 生成邮件的代码是: from mailer import send_mail from notificat

我刚刚实现了django mailer,因为它似乎是从django异步发送邮件的最佳方式

出于某种原因,正在为收件人电子邮件地址的每个字母创建一个db条目,其中“收件人”字段中有一个字母。。。。以下是一个屏幕截图:

为了不显示完整的地址,我删掉了其余的条目,但足以说明所有条目的“收件人”字段加起来就是用户的电子邮件地址。(为了澄清,发送一封电子邮件会为电子邮件地址的每个字母创建一个对象)

生成邮件的代码是:

from mailer import send_mail
from notifications.models import EmailNotifications

users_to_email = EmailNotifications.objects.filter(\
                            product=product)
    if users_to_email:
        for user_to_email in users_to_email:
            the_score = self.rating
            user = user_to_email.user
            name = '%s %s' % (str(user.first_name),\
                                    str(user.last_name))
            user_email = user.email
            theSubject = 'Score Notification'
            theMessage = render_to_string('notification-email.txt',
                                   {'the_score': the_score,
                                    'name': name,
                                    'user': user,
                                    'user_email': user_email})
                send_mail(theSubject, theMessage, SERVER_EMAIL,\
                                                        user_email)
在通知电子邮件中输出
user\u email
可以正确地给出整个电子邮件地址,因此我假设这是django mailer保存功能的问题


非常感谢您的指点。

好的,在所有这些之后,我自己解决了,当然,我犯了一个严重的n00b错误

发送邮件
需要收件人列表。我应该做的是:

send_mail(subject, message, SERVER_EMAIL, [user_email])
请注意用户电子邮件周围的方括号,使其成为一个列表。。。。。现在一切都好了