2015-03-07 20:55:59 +08:00
|
|
|
import datetime
|
|
|
|
import socket
|
|
|
|
|
|
|
|
from django.core.mail import send_mail
|
2015-03-21 05:57:11 +08:00
|
|
|
from django.core.management.base import BaseCommand
|
2015-03-07 20:55:59 +08:00
|
|
|
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "Sends a test email to the email addresses specified as arguments."
|
2015-03-21 03:23:43 +08:00
|
|
|
|
|
|
|
def add_arguments(self, parser):
|
|
|
|
parser.add_argument('email', nargs='+',
|
|
|
|
help='One or more email addresses to send the test mail to.')
|
2015-03-07 20:55:59 +08:00
|
|
|
|
|
|
|
def handle(self, *args, **kwargs):
|
|
|
|
send_mail(
|
|
|
|
subject='Test email from %s on %s' % (socket.gethostname(), datetime.datetime.now()),
|
|
|
|
message="If you\'re reading this, it was successful.",
|
|
|
|
from_email=None,
|
2015-03-21 03:23:43 +08:00
|
|
|
recipient_list=kwargs['email'],
|
2015-03-07 20:55:59 +08:00
|
|
|
)
|