Last active
July 3, 2020 10:19
-
-
Save nskeip/d6b0bc023c760344a80ff09a7e9ae275 to your computer and use it in GitHub Desktop.
Django command to test sending a simple email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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