mirror of
https://github.com/fergalmoran/mailex.git
synced 2025-12-22 09:17:35 +00:00
Fixed up arguments
This commit is contained in:
19
README.md
19
README.md
@@ -1 +1,20 @@
|
||||
Simple python script to send email with attachments from the command line
|
||||
|
||||
usage: mailex.py [-h] [-v] -t TO_ADDRESS [-f [FROM_ADDRESS]] [-a ATTACHMENTS]
|
||||
[-s [SUBJECT]] [-b [MAIL_BODY]]
|
||||
|
||||
optional arguments:
|
||||
-h, --help show this help message and exit
|
||||
-v, --version show program's version number and exit
|
||||
-t TO_ADDRESS, --to-address TO_ADDRESS
|
||||
To address
|
||||
-f [FROM_ADDRESS], --from-address [FROM_ADDRESS]
|
||||
From address
|
||||
-a ATTACHMENTS, --attachments ATTACHMENTS
|
||||
File(s) to attach
|
||||
-s [SUBJECT], --subject [SUBJECT]
|
||||
Mail subject
|
||||
-b [MAIL_BODY], --mail-body [MAIL_BODY]
|
||||
Mail body
|
||||
fergalm@FERGAL-NIX-LT ~/Dropbox/Private/mailex $
|
||||
|
||||
|
||||
12
mailex.py
12
mailex.py
@@ -41,18 +41,18 @@ def _get_default_from():
|
||||
return "%s@%s" % (getpass.getuser(), socket.gethostname())
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser = argparse.ArgumentParser(description='Sends email, inclucing attachments, from the command line')
|
||||
#commands
|
||||
parser.add_argument("-v", "--version", action="version", version="0.1")
|
||||
|
||||
#required
|
||||
parser.add_argument("-t", "--to-address", help="To address", required=True)
|
||||
parser.add_argument("-t", "--to-address", metavar="TO", help="To address", required=True)
|
||||
|
||||
#optional
|
||||
parser.add_argument("-f", "--from-address", nargs="?", default=_get_default_from(), help="From address")
|
||||
parser.add_argument("-a", "--attachments", help="File(s) to attach")
|
||||
parser.add_argument("-s", "--subject", nargs="?", help="Mail subject", default="")
|
||||
parser.add_argument("-b", "--mail-body", nargs="?", help="Mail body", default="")
|
||||
parser.add_argument("-f", "--from-address", metavar="FROM", default=_get_default_from(), help="From address")
|
||||
parser.add_argument("-a", "--attachments", nargs="?", help="File(s) to attach")
|
||||
parser.add_argument("-s", "--subject", metavar="SUBJ", help="Mail subject", default="")
|
||||
parser.add_argument("-b", "--mail-body", metavar="BODY", help="Mail body", default="")
|
||||
args = parser.parse_args()
|
||||
|
||||
#read any piped text
|
||||
|
||||
Reference in New Issue
Block a user