Django ';CustomEmailBackend';对象没有属性';请求';
我正在尝试将smtp后端子类化为django,并且我希望能够访问self.request或request,我遇到以下错误:Django ';CustomEmailBackend';对象没有属性';请求';,django,Django,我正在尝试将smtp后端子类化为django,并且我希望能够访问self.request或request,我遇到以下错误: 'CustomEmailBackend' object has no attribute 'request' 这是我的EmailBackend的子类 from django.core.mail.backends.smtp import EmailBackend class CustomEmailBackend(EmailBackend):
'CustomEmailBackend' object has no attribute 'request'
这是我的EmailBackend的子类
from django.core.mail.backends.smtp import EmailBackend
class CustomEmailBackend(EmailBackend):
def send_messages(self, email_messages):
if not email_messages:
return 0
with self._lock:
new_conn_created = self.open()
if not self.connection or new_conn_created is None:
return 0
num_sent = 0
for message in email_messages:
#set default for this message
deliverable = True
#get list of recipients on message
recipients = message.recipients()
for recipient in recipients:
emailvalidation = email_validation(recipient)
if emailvalidation.result == "Safe to Send":
pass
else:
deliverable = False
if deliverable == True:
sent = self._send(message)
if sent:
num_sent += 1
else:
messages.error(self.request, 'Email address invalid. Email was not sent.')
if new_conn_created:
self.close()
return num_sent