mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-10 06:48:19 +02:00
Added tests, refactoring
This commit is contained in:
parent
e3c57c3c14
commit
9bc97119e3
3 changed files with 41 additions and 18 deletions
|
|
@ -7,13 +7,12 @@ class Command(BaseCommand):
|
|||
help = 'Sends an e-mail to specified recipient'
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('from', type=int, help='ID (pk) for the mailbox you want to use to send an e-mail')
|
||||
parser.add_argument('to', help='E-mail address of recipient')
|
||||
parser.add_argument('subject', help='Subject of letter')
|
||||
parser.add_argument('body', help='Message')
|
||||
parser.add_argument('from', type=int, help='ID (pk) for the mailbox you want to use to send an e-mail')
|
||||
parser.add_argument('to', type=str, help='E-mail address of recipient')
|
||||
parser.add_argument('subject', type=str, help='Subject of letter')
|
||||
parser.add_argument('body', type=str, help='Message')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
|
||||
from_email = options.get('from')
|
||||
to = options.get('to')
|
||||
subject = options.get('subject')
|
||||
|
|
@ -22,6 +21,6 @@ class Command(BaseCommand):
|
|||
mailbox = Mailbox.objects.get(pk=from_email)
|
||||
self.stdout.write(self.style.WARNING("-"*36 + "\nFrom: %s \nTo: %s \nSubject: %s \nMessage: %s \n" %
|
||||
(mailbox.from_email,
|
||||
to, subject, body) + '-'*36))
|
||||
if mailbox.send_mail(options.get('subject'), options.get('to'), options.get('body')):
|
||||
to, subject, body) + '-'*36))
|
||||
if mailbox.send_mail(subject, to, body):
|
||||
self.stdout.write(self.style.SUCCESS('The letter is sent.'))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue