Menu

1 / 2

Django: Send Email with send_mail() in 5 Minutes — Configure SMTP the Right Way

DEV Community: django·Linh Fish Dev·3 days ago
#XxQosOve
#devtodjango#devto#dev#send#django
Reading 0:00
15s threshold

Django already ships with send_mail() — configure SMTP once in settings.py and you can send email with a single call. Use it for welcome emails after registration, order confirmations, password resets, or system notifications. No extra library to install, and no hand-rolled SMTP code with smtplib .

The Problem

Many new projects call send_mail() right away without configuring anything, assuming Django “just knows” where to send mail. In reality Django defaults to an SMTP backend pointing at localhost:25 — most dev machines have no mail server, so the request hangs and then fails with ConnectionRefusedError , and users who just registered wait forever for a welcome email that never arrives. Another common mistake is hardcoding the email password straight into settings.py and accidentally committing it to Git — the mailbox gets exposed and abused to send spam.

from django.core.mail import send_mail

send_mail ( " Chao mung ban den voi MyShop " , " Cam on ban da dang ky tai khoan.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.