1 | #!/usr/bin/env python
|
---|
2 | #
|
---|
3 | # Run the Mailjam MTA client
|
---|
4 |
|
---|
5 | import argparse, sys
|
---|
6 | from mailjam.mta import MTAClient
|
---|
7 |
|
---|
8 | msg = 'mailjam-mta: Mailing lists MTA client'
|
---|
9 | parser = argparse.ArgumentParser(description=msg)
|
---|
10 | parser.add_argument('-c', '--config', action='store', dest='config',
|
---|
11 | help='Set the path to a valid mailjam mta client configuration file')
|
---|
12 | parser.add_argument('-v', '--version', action='version',
|
---|
13 | version='mailjam mta client 0.1.0')
|
---|
14 | parser.add_argument('-a', '--address', action='store', dest='address',
|
---|
15 | required=True,
|
---|
16 | help='Set the address of the mailing list we want to manage')
|
---|
17 |
|
---|
18 | parser.add_argument('-i', '--input', type=argparse.FileType('r'),
|
---|
19 | default='-', required=True, dest='input',
|
---|
20 | help="Pass the raw email to be send to the mailing list, Use - to allow incoming raw mails from a pipe")
|
---|
21 |
|
---|
22 | if __name__ == '__main__':
|
---|
23 | results = parser.parse_args()
|
---|
24 | if results.config:
|
---|
25 | mta_client = MTAClient(address=results.address,
|
---|
26 | configfile=results.config)
|
---|
27 | else:
|
---|
28 | mta_client = MTAClient(address=results.address)
|
---|
29 | mta_client.get_raw_email(results.input.read())
|
---|
30 | mta_client.run()
|
---|
31 |
|
---|