0
我正在開發一個需要發送html郵件的項目。一個url需要插入html內容,如Django的html電子郵件
<p><a href="http://dealerfunnel.com/passwordchange">Password Change Link</a></p>
我的域名,dealerfunnel.com
。如果我把任何有效的網址除http://dealerfunnel.com然後電子郵件發送。就像如果我把
google.com
然後,通過電子郵件發送。但是當我把dealerfunnel.com
,電子郵件不發送,並沒有得到任何錯誤。
請檢閱我的代碼:
from dealerfunnel.funnel.view.base import *
from django.template.loader import get_template
from django.core.mail import EmailMessage
import sys
class debug():
def sendmail(self,request):
message = get_template('mail/forgot.html').render(Context({"name":"Khalid Hossain"}))
try:
msg = EmailMessage('Password Change',message, to=['[email protected]'], from_email='[email protected]')
msg.content_subtype = 'html'
msg.send()
return HttpResponse(message)
except :
e = sys.exc_info()[0]
return HttpResponse(e)
爲什麼不使用Django的[重置密碼](https://docs.djangoproject.com/en/1.8/topics/auth /default/#module-django.contrib.auth.views)表單? – Sayse
顯示你的settings.py – fledgling
和你的網址,你不應該硬編碼一個頁面鏈接,你應該使用'url'模板標籤 – Sayse