... r on a module-level function: from django.core.mail import send_mail from django.tasks import task @task def email_users ( emails , subject , message ): return send_mail ( subject = subject , message = message , from_email = None , recipient_list = ema ... rator arguments: from django.core.mail import send_mail from django.tasks import task @task ( priority = 2 , queue_name = "emails" ) def email_users ( emails , subject , message ): return send_mail ( subject = subject , message = message , from_email = ... None , recipient_list = emails ) By convention, Tasks are defined in a tasks.py file, however this is not enforced. Task context Sometimes, the running T ... ... or a file during development and an SMTP server or email service provider in production. コードは django.core.mail モジュールにあります。 簡単な例 簡単なメール送信には send_mail() ... nd_mail send_mail ( "Subject here" , "Here is the message." , "from@example.com" , [ "to@example.com" ], ) When additional email sending functionality is needed, use the EmailMessage or EmailMultiAlternatives class. For example, to send a multipart ema ... mplate.loader import render_to_string # First, render the plain text content. text_content = render_to_string ( "templates/emails/my_email.txt" , context = { "my_variable" : 42 }, ) # Secondly, render the HTML content. html_content = render_to_string ( ... ... in Tasks framework for running code outside the HTTP request–response cycle. This enables offloading work, such as sending emails or processing data, to background workers. The framework provides task definition, validation, queuing, and result handlin ... d using the task() decorator: from django.core.mail import send_mail from django.tasks import task @task def email_users ( emails , subject , message ): return send_mail ( subject , message , None , emails ) Once defined, tasks can be enqueued through ... a configured backend: email_users . enqueue ( emails = [ "user@example.com" ], subject = "You have a message" , message = "Hello there!" , ) Backends are configured via the TA ... ... ... ... cache effectively work on a per-session basis regardless of the CACHE_MIDDLEWARE_ANONYMOUS_ONLY setting. SEND_BROKEN_LINK_EMAILS setting CommonMiddleware used to provide basic reporting of broken links by email when SEND_BROKEN_LINK_EMAILS is set to T ... ering problems between CommonMiddleware and LocaleMiddleware , this feature was split out into a new middleware: BrokenLinkEmailsMiddleware . If you're relying on this feature, you should add 'django.middleware.common.BrokenLinkEmailsMiddleware' to you ... r MIDDLEWARE_CLASSES setting and remove SEND_BROKEN_LINK_EMAILS from your settings. _has_changed method on widgets If you defined your own form widgets and defined the _has_changed metho ... ... ct. A number of logging handlers and logging calls have been added to Django's own code as well -- most notably, the error emails sent on an HTTP 500 server error are now handled as a logging activity. See the documentation on Django's logging interfac ... and mail_managers() はメッセージにHTMLコンテンツを簡単に添付できるようになりました。 EmailMessage now supports CC's. Error emails now include more of the detail and formatting of the debug server error page. simple_tag() now accepts a takes_context arg ... ... icially supports. Request exceptions are now always logged When we added logging support in Django in 1.3, the admin error email support was moved into the django.utils.log.AdminEmailHandler , attached to the 'django.request' logger. In order to mainta ... in the established behavior of error emails, the 'django.request' logger was called only when DEBUG was False . To increase the flexibility of error logging for reque ... file for new projects now includes a separate filter attached to django.utils.log.AdminEmailHandler to prevent admin error emails in DEBUG mode: LOGGING = { # ... "filters" : { "require_debug_false" : { "()" : "django.utils.log.RequireDebugFalse" , } } ... ... This guide provides details on migrating existing projects to the new mailers functionality. All Django projects that send email should: If using any third-party packages that send email, verify their compatibility with MAILERS before making other chan ... natives to that package), you will need to remove MAILERS from your settings and replace it with the equivalent deprecated email settings until the package has been updated. If those errors are coming from your own code, see the other sections in this ... False should be updated to remove the fail_silently arg, as that is the default. If you use AdminEmailHandler or BrokenLinkEmailsMiddleware and rely on their previous fail-silent behavior, see Ignoring transient failures in error reporting . Migrating ... ... djangoproject.com as a "Site maintainer". Access to create a post in the Django Forum - Announcements category and to send emails to the django-announce mailing list. Access to the django-security repo in GitHub. Among other things, this provides acces ... 2026年10月08日