2

私は人々が電子メールを提出することができるページを持っています。それは動作しますが、私はそれからすべての電子メールを受け取ります。

ビューは次のとおりです。

def signup(request):
  if request.method == 'POST': # If the form has been submitted...
    form = SignUpForm(request.POST) # A form bound to the POST data
    if form.is_valid(): # All validation rules pass
        subject = form.cleaned_data['subject']
        message = form.cleaned_data['message']
        sender = form.cleaned_data['sender']
        recipients = ['illuminatirebellion@gmail.com']

        from django.core.mail import send_mail
        send_mail(subject, message, sender, recipients)
        return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
     form = SignUpForm() # An unbound form
return render_to_response('signup.html', {'form': form,},context_instance=RequestContext(request))

そして設定:

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'illuminatirebellion@gmail.com'
EMAIL_HOST_PASSWORD = 'mypassword'
EMAIL_PORT = 587
MANAGERS = ADMINS
4

1 に答える 1

1

の使い方はsend_mail()正しいようです。

From:Gmail が SMTP ベンダーであると仮定すると、Gmail はカスタムメール アドレスの使用をサポートしていないようです。

関連する:

于 2012-04-14T17:56:52.697 に答える