当用户提交“请求”表单时,我的应用程序会发送一封包含请求表单内容的电子邮件,并应使用他们输入的电子邮件地址作为电子邮件中的“发件人:”。出于某种原因,它似乎使用EMAIL_HOST_USER电子邮件而不是“发件人:”。
views.py
def beta_request(request):
if request.method == 'POST':
email = request.POST.get("email")
name = request.POST.get("name")
message = request.POST.get("message")
send_mail('Subject', 'Message', str(email), ['team@email.com'])
settings.py
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'me@email.com'
EMAIL_HOST_PASSWORD = 'pass'
SERVER_EMAIL = EMAIL_HOST_USER
request.html
<form action="/beta_request/" method="post" accept-charset="UTF-8">
<input id="name" type="text" name="name">
<input id="email" type="email" name="email">
<input id="message" type="text" name="message">
<button class="btn" type="Submit" value="Submit">Submit</button>
</form>
有关如何将“发件人:”字段更改为用户的输入电子邮件而不是我的EMAIL_HOST_USER的任何建议?