问题描述
在当前阶段,电子邮件可以正常工作,但是,在接收实际邮件时,图像未附加,而是显示名称。我希望显示附件以便能够下载。
def publication(request):
if request.method == "POST":
inputImmagine1 = request.POST['inputImmagine1']
send_mail(
'Richiesta di pubblicazione - Condoglianze',#subject
inputImmagine1,#message
inputEmail,# from email
['XXX@gmail.com'],# to email
)
return render(request,'publication.html',{'inputImmagine1': inputImmagine1})
else:
return render(request,{})
解决方法
您可以使用from django.core.mail import EmailMessage
email = EmailMessage(
'Hello','Body goes here','from@example.com',['to1@example.com','to2@example.com'],)
email.attach_file('/logo.png')
email.send()
类附加文件
{{1}}
编辑:要处理在前端上传的文件,请选中Django docs for file uploads。