render_to_string
: 템플릿을로드하고 렌더링 한 다음 결과로 string
을 반환합니다. html_message
: html_message
이 제공되면 기본 메시지가 Html 메시지로 바뀝니다.
메일/HTML-message.html
Hi {{ first_name }}.
This is your {{ email }}
Thank you
views.py
def mail_function(request):
subject = 'Test Mail'
from = '[email protected]'
to = '[email protected]'
c = Context({'email': email,
'first_name': first_name})
html_content = render_to_string('mail/html-message.html', c)
txtmes = render_to_string('mail/text-message.html', c)
send_mail(subject,
txtmes,
from,
[to],
fail_silently=False,
html_message=html_content)