0
연락처 양식에서 작업하고 장고에서받은 편지함으로 전자 메일을받을 수 없습니다. Django가 전자 메일 알림을 보내지 않습니다.
이
내 기능입니다 :def contact(request):
if request.method == 'GET':
form = ContactForm()
else:
form = ContactForm(request.POST)
if form.is_valid():
contact_name = form.cleaned_data['contact_name']
contact_phone = form.cleaned_data['contact_phone']
contact_period = form.cleaned_data['contact_period']
subject = contact_name + " | " + contact_phone + " | " + contact_period
content = form.cleaned_data['content']
contact_email = form.cleaned_data['contact_email']
try:
send_mail(subject,content,contact_email, ['[email protected]'])
except BadHeaderError:
return HttpResponse('Invalid header found.')
return redirect('success')
return render(request, "contact.html", {'form': form})
def success(request):
return HttpResponse('Success! Thank you for your message.')
이 내 서버의 설정은 다음과 같습니다
Secure SSL/TLS Settings (Recommended)
Username: [email protected]
Password: Use the email account’s password.
Incoming Server: mail.cohen.ro
IMAP Port: 993 POP3 Port: 995
Outgoing Server: mail.cohen.ro
SMTP Port: 465
이 내가 내 장고 설정에있을 것입니다 : LATEREDIT : 나는 콘솔 댓글을 달았 지금 가지고있다 이 코드 행은 이메일을 제출하지 않습니다.
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
#EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
DEFAULT_FROM_EMAIL = '[email protected]'
EMAIL_HOST= 'mail.cohen.ro'
EMAIL_HOST_USER= '[email protected]'
EMAIl_HOST_PASSWORD='mypass'
EMAIL_PORT = 465
EMAIL_USE_TLS = True
내 서버에서 메시지를 볼 수는 있지만 내 이메일 주소로 전자 메일을 보내지 않으므로 다른 사람이 나에게 묻는다면 잘 모릅니다. 고맙습니다!
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: me | 0787877 | 12-13
From: [email protected]
To: [email protected]
Date: Mon, 25 Dec 2017 11:29:39 -0000
Message-ID: <[email protected]>
me
내가 가진 오류 :
SMTPServerDisconnected at /contact/
Connection unexpectedly closed
Request Method: POST
Request URL: http://127.0.0.1:8000/contact/
Django Version: 2.0
Exception Type: SMTPServerDisconnected
Exception Value:
Connection unexpectedly closed
Exception Location: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/smtplib.py in getreply, line 393
Python Executable: /Users/cohen/PycharmProjects/chn/venv/bin/python
Python Version: 3.6.1
Python Path:
['/Users/cohen/PycharmProjects/chn',
'/Users/cohen/PycharmProjects/chn',
'/Users/cohen/PycharmProjects/static_in_env',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python36.zip',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6',
'/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/lib-dynload',
'/Users/cohen/PycharmProjects/chn/venv/lib/python3.6/site-packages',
'/Users/cohen/PycharmProjects/chn/venv/lib/python3.6/site-packages/setuptools-28.8.0-py3.6.egg',
'/Users/cohen/PycharmProjects/chn/venv/lib/python3.6/site-packages/pip-9.0.1-py3.6.egg',
'/Applications/PyCharm.app/Contents/helpers/pycharm_matplotlib_backend']
Server time: Mon, 25 Dec 2017 13:49:16 +0200
어떤 도움을 많이 주시면 감사하겠습니다!
복사 - 붙여 넣기 수정 실수가 아닌지 확실하지 않지만'EMAIL_HOST_PASSWORD'에는 email :'EMAIl'이라는 단어에 소문자'L'이 포함되어 있습니다. – Nrzonline