Django

Django Email

Email backend, send_mail, EmailMessage, HTML emails, attachments, async email, Celery integration

18 面接問題·
Mid-Level
1

Which Django setting configures the email sending backend?

回答

The EMAIL_BACKEND setting configures the email sending backend in Django. By default, it uses smtp.EmailBackend which sends emails via SMTP. In development, it's common to use console.EmailBackend to display emails in the console or filebased.EmailBackend to save them to files.

2

Which Django function allows sending a simple email with a subject, message, and recipient list?

回答

The send_mail function from django.core.mail is the simplest method to send an email in Django. It takes as required parameters the subject, message, sender, and recipient list. It returns the number of successfully sent emails (0 or 1).

3

Which email backend to use in development to display emails in the console instead of sending them?

回答

The django.core.mail.backends.console.EmailBackend backend displays emails in standard output (console) instead of actually sending them. This is ideal for development as it allows checking email content without SMTP configuration and without risking sending test emails to real recipients.

4

Which Django class to use for creating an email with more control than send_mail, including adding custom headers?

5

How to send an HTML email with a text fallback version in Django?

+15 面接問題

次の面接に向けてDjangoをマスター

すべての問題、flashcards、技術テスト、コードレビュー演習、面接シミュレーターにアクセス。

無料で始める