-1

django を使用してダイレクト メール メッセージを送信しようとしています。エラーは発生しませんが、メッセージは受信者の電子メールに送信されません。コードに問題はありますか?

VIEWS.PY

def contact(request):
if request.method == 'POST': # If the form has been submitted...
    form = ContactForm(request.POST) # A form bound to the POST data
    if form.is_valid():
        subject = form.cleaned_data['subject']
        message = form.cleaned_data['message']
        sender = form.cleaned_data['sender']
        cc_myself = form.cleaned_data['cc_myself']

        recipients = ['canonizadocharm@ymail.com']
        if cc_myself:
            recipients.append(sender)

        from django.core.mail import send_mail
        send_mail(subject, message, sender, recipients)
        return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
    form = ContactForm() # An unbound form

return render(request, 'contact.html', {
    'form': form,
})

モデル.PY

class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)

設定.PY

EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/app-messages' # change this to a proper location

# Sending mail
EMAIL_USE_TLS = False
EMAIL_HOST='localhost'
EMAIL_PORT= 25
EMAIL_HOST_USER=''
EMAIL_HOST_PASSWORD=''
4

1 に答える 1

2
recipients = ['canonizadocharm@ymail.com',]


EMAIL_USE_TLS = True
EMAIL_HOST='smtp.gmail.com'
EMAIL_PORT=587
EMAIL_HOST_USER='your gmail account'
EMAIL_HOST_PASSWORD='your gmail password'
于 2013-02-08T06:50:02.853 に答える