diff --git a/mutt.py b/mutt.py index 4217a0f..7893be1 100755 --- a/mutt.py +++ b/mutt.py @@ -1,7 +1,8 @@ #!/usr/bin/env python -''' -This script provides a flexible wrapper for mailing files from a remote server with mutt +""" +This script provides a flexible wrapper for mailing files from a remote server +with mutt. USAGE: mutt.py -s "Subject line" -r "address1@gmail.com, address2@gmail.com" -rt "my.address@internets.com" -m "This is my email message" /path/to/attachment1.txt /path/to/attahment2.txt @@ -12,31 +13,27 @@ mutt -s "$SUBJECT_LINE" -a "$attachment_file" -a "$summary_file" -a "$zipfile" -- "$recipient_list" < 0: for file in attachment_files: @@ -45,21 +42,24 @@ def make_attachement_string(attachment_files): attachment_string = ''.join(attachment_strings) return(attachment_string) + def get_file_contents(file): - ''' - Return a string containing all lines in the file - ''' + """Return a string containing all lines in the file.""" lines_list = [] with open(file) as f: for line in f: lines_list.append(line) return(''.join(lines_list)) -def mutt_mail(recipient_list, reply_to, subject_line, message, message_file, attachment_files): - ''' - Send the message with mutt - ''' - if message_file != None: + +def mutt_mail(recipient_list, + reply_to, + subject_line, + message, + message_file, + attachment_files): + """Send the message with mutt.""" + if message_file is not None: message = get_file_contents(message_file) attachment_string = make_attachement_string(attachment_files) command = ''' @@ -67,27 +67,47 @@ def mutt_mail(recipient_list, reply_to, subject_line, message, message_file, att mutt -s "{1}" {2} -- "{3}" <