Skip to content

Instantly share code, notes, and snippets.

@nskeip
Last active July 3, 2020 10:19
Show Gist options
  • Save nskeip/d6b0bc023c760344a80ff09a7e9ae275 to your computer and use it in GitHub Desktop.
Save nskeip/d6b0bc023c760344a80ff09a7e9ae275 to your computer and use it in GitHub Desktop.
Django command to test sending a simple email
from django.core.mail import send_mail
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'Tests sending a simple email.'
def add_arguments(self, parser):
parser.add_argument('subject')
parser.add_argument('message')
parser.add_argument('from_email')
parser.add_argument('to_email')
def handle(self, *args, **options):
send_mail(
options.get('subject'),
options.get('message'),
options.get('from_email'),
[options.get('to_email')],
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment