html = render_to_string(
"users/register_email.html",
{
"backend_base_url": settings.BACKEND_BASE_URL,
"uidb64": urlsafe_base64_encode(force_bytes(user.id)).encode().decode(),
"token": account_activation_token.make_token(user),
},
)
to_email = user.email
send_mail(
"안녕하세요 Cookai입니다. 인증메일이 도착했어요!",
"_",
settings.DEFAULT_FROM_MAIL,
[to_email],
html_message=html,
)
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(BASE_DIR, "templates")],
경로 설정 후 템플릿 작성
{% autoescape off %}
<!DOCTYPE html>
<html>
<body>
<div style="width:100%;min-width:100%;height:100%;">
<div style="padding: 70px 0; background: #f7f8f9;">
<div style="margin: 0 auto; width: 600px; color: #000;">
<div style="padding: 30px 90px; text-align: center; border: 1px solid #dfdfdf; background: #fff;">
<h3 style="margin-bottom: 35px; font-size: 30px; font-weight: 600;">회원가입 이메일 인증 발송</h3>
<div style="padding: 10px 0 20px; border-top: 1px solid rgb(172, 172, 172);">
<p style="font-size: 14px; font-weight: 600; line-height: 20px;">Cookai 홈페이지 회원가입을 축하드립니다.<br>아래 링크를 클릭하여 로그인 해주시기 바랍니다.</p>
</div>
<div style="padding: 20px 30px; background: #f7f8f9;"><a style="font-size: 18px; font-weight: bold; text-decoration:none; color:black;" href="{{ backend_base_url }}/users/activate/{{ uidb64 }}/{{ token }}">인증하기</a></div>
</div>
</div>
</div>
</div>
</body>
</html>
{% endautoescape %}
참고
이메일 보낼때 email=Emailmessage(), email.send()로 하면 장고 템플릿이 먹히지 않는다! send_email()을 쓰자