Skip to content

Commit

Permalink
Allow fake run without providing server and authentication (ASPP#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobj authored and keszybz committed Aug 28, 2017
1 parent c233af8 commit 3435b98
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions massmail
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def parse_command_line_options(arguments):
if len(options['from']) == 0:
error('You must set a from address with option -F')

if options['server'] is None:
if options['server'] is None and not options['fake']:
error('You must set a SMTP server with option -z')

if options['sep'] == ",":
Expand Down Expand Up @@ -273,9 +273,10 @@ def add_email_headers(options, msgs):
return None

def send_messages(options, msgs):
server = smtplib.SMTP(options['server'], port=options['port'])
if not options['fake']:
server = smtplib.SMTP(options['server'], port=options['port'])

if options['smtpuser'] is not None:
if options['smtpuser'] is not None and not options['fake']:
server.starttls()
server.login(options['smtpuser'], options['smtppassword'])

Expand All @@ -295,7 +296,8 @@ def send_messages(options, msgs):
if len(out) != 0:
error(str(out))

server.close()
if not options['fake']:
server.close()

def main(arguments):
options = parse_command_line_options(arguments)
Expand Down

0 comments on commit 3435b98

Please sign in to comment.