Django – send_mail SMTP 메일 보내기

장고 기반의 프로젝트에서 이메일로 처리해야 할 일이 제법 있다.

가장 간단하게는 비밀번호를 잊었을 때 복구 링크 보내주는 것이 대표적인 예로 볼 수 있다.

장고 문서 공식 사이트에서는, 아래 링크에서 정보를 찾을 수 있다.

https://docs.djangoproject.com/en/4.1/topics/email/

settings.py

아래 링크에 가면 아주 자세하게 설정해서 보내는 샘플 프로젝트가 잘 되어 있다.

https://opensource.com/article/22/12/django-send-emails-smtp

Scroll to the end of the code and update the file with the following code:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.yourserver.com'
EMAIL_USE_TLS = False
EMAIL_PORT = 465
EMAIL_USE_SSL = True
EMAIL_HOST_USER = 'your@djangoapp.com'
EMAIL_HOST_PASSWORD = 'your password'

send_mail()

함수 호출은 단순하다.

<pre class="wp-block-preformatted"><strong>from</strong> <strong>django.core.mail</strong> <strong>import</strong> send_mail

send_mail(
    'Subject here',
    'Here is the message.',
    'from@example.com',
    ['to@example.com'],
    fail_silently=<strong>False</strong>,
)
![email, newsletter, email marketing](assets/images/2023/01/3249062-1024x573.jpg?resize=1024%2C573)
sending email

무료 한글 폰트 추천

2개 정도 소개한다.

Pretendard

이름도 잘 만드시네, 그만큼 품질도 엄청 좋다

https://cactus.tistory.com/306

그림으로 글자를 살펴보면, 간단하게 위의 페이지에서 캡쳐해봤다. Noto Sans와 비교해서 굵기를 표기한 그림이다.

![](assets/images/2023/01/image-1.png?resize=1024%2C491&ssl=1)

Suite

고급스런 이름이다. 아래 페이지를 참고하고

웹폰트

https://sunn.us/suite/#keypoint
스위트라는 한글 폰트, 여러모로 유용하게 쓸 수 있겠다.
![](assets/images/2023/01/image-2.png?resize=1024%2C260&ssl=1)

사용법은 아래와 같다.

Static

<link href="https://cdn.jsdelivr.net/gh/sunn-us/SUITE/fonts/static/woff2/SUITE.css" rel="stylesheet"><br></br><br></br><style><br></br>    * {font-family: 'SUITE', sans-serif;}<br></br></style>

Variable

<link href="https://cdn.jsdelivr.net/gh/sunn-us/SUITE/fonts/variable/woff2/SUITE-Variable.css" rel="stylesheet"><br></br><br></br><style><br></br>    * {font-family: 'SUITE Variable', sans-serif;}<br></br></style>