Python 在Django中通过Amazon SES发送电子邮件时,如何更改显示名称?
目前,我在Django使用Amazon SES发送电子邮件 我的设置看起来像这样。在settings.py中,我有:Python 在Django中通过Amazon SES发送电子邮件时,如何更改显示名称?,python,django,amazon-ses,Python,Django,Amazon Ses,目前,我在Django使用Amazon SES发送电子邮件 我的设置看起来像这样。在settings.py中,我有: EMAIL_HOST = 'email-smtp....' EMAIL_PORT = 25 EMAIL_HOST_USER = 'my-email-host-user' EMAIL_HOST_PASSWORD = 'my-email-host-password' EMAIL_USE_TLS = True 我认为: from django.shortcuts import ren
EMAIL_HOST = 'email-smtp....'
EMAIL_PORT = 25
EMAIL_HOST_USER = 'my-email-host-user'
EMAIL_HOST_PASSWORD = 'my-email-host-password'
EMAIL_USE_TLS = True
我认为:
from django.shortcuts import render
from django.http import HttpResponse
from django.conf import settings
from django.contrib import messages
from django.core.mail import send_mail
from django.core.mail import EmailMessage
def index(request):
email_message = EmailMessage('This is a title', 'This is a message body', 'FromEmail@example.com', ['ToEmail@example.com'])
email_message.send()
return HttpResponse("You just sent an email message.")
当我打开消息时,我在标题中看到:
FromEmail@example.com via amazonses.com
我想定制它,以便我可以执行以下操作:
UserFirstName UserLastName via amazonses.com
email_message = EmailMessage('This is a title', 'This is a message body', 'UserFirstName UserLastName <FromEmail@example.com>', ['ToEmail@example.com'])
UserFirstName UserLastName <FromEmail@example.com>
我该怎么做呢?我怀疑您是否可以,但您应该能够使用以下地址:
UserFirstName UserLastName via amazonses.com
email_message = EmailMessage('This is a title', 'This is a message body', 'UserFirstName UserLastName <FromEmail@example.com>', ['ToEmail@example.com'])
UserFirstName UserLastName <FromEmail@example.com>
email\u message=EmailMessage('这是标题','这是邮件正文','UserFirstName',['ToEmail@example.com'])
这将导致电子邮件客户端显示发件人地址,如下所示:
UserFirstName UserLastName via amazonses.com
email_message = EmailMessage('This is a title', 'This is a message body', 'UserFirstName UserLastName <FromEmail@example.com>', ['ToEmail@example.com'])
UserFirstName UserLastName <FromEmail@example.com>
UserFirstName UserLastName
这正是我想要的。我并不是想把这个问题从我的例子中漏掉。谢谢