Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
551 views
in Technique[技术] by (71.8m points)

python - send_mail() missing 1 required positional argument: 'recipient_list'

Why i am receiving this error? send_mail() missing 1 required positional argument: 'recipient_list' did i miss something?

from django.core.mail import send_mail
from django.template import Context, loader


def contact(request):

     Email = request.POST['Email']
     ....


     email_template = loader.get_template('accounts/print.html')
     send_mail(email_template, [settings.EMAIL_HOST_USER], Email, fail_silently=False)

Update

email_template = loader.get_template('accounts/print.html')

send_mail('Your Enrollment: ', email_template, [Email], [settings.EMAIL_HOST_USER], fail_silently=False)

this is the error i receive 'Template' object has no attribute 'splitlines'

question from:https://stackoverflow.com/questions/65894899/send-mail-missing-1-required-positional-argument-recipient-list

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think send_mail is expecting the positional argument recipients_list to be of the type list:

send_mail(email_template, [settings.EMAIL_HOST_USER], Email, fail_silently=False)

needs to be

send_mail(email_template, [settings.EMAIL_HOST_USER], [Email], Email, fail_silently=False)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...