Created
July 11, 2014 03:16
-
-
Save gcmurphy/a37a0e7ea85a63f3d6c4 to your computer and use it in GitHub Desktop.
draft an email using mutt..
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
def draft_email(**kwargs): | |
cmd = ["mutt"] | |
if 'to' in kwargs: | |
cmd.append(",".join(kwargs.get('to'))) | |
if 'subject' in kwargs: | |
cmd.append("-s") | |
cmd.append(kwargs.get('subject')) | |
if 'body' in kwargs and os.path.exists(kwargs.get('body')): | |
cmd.append("-i") | |
cmd.append(kwargs.get('body')) | |
if 'attachments' in kwargs: | |
for attachment in kwargs.get('attachments'): | |
cmd.append("-a") | |
cmd.append(attachment) | |
if 'bcc' in kwargs: | |
cmd.append("-b") | |
cmd.append(",".join(kwargs.get('bcc'))) | |
if 'cc' in kwargs: | |
cmd.append("-c") | |
cmd.append(",".join(kwargs.get('cc'))) | |
subprocess.call(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment