Initial commit
bn8 authored 11 years ago
|
35)
36) import logging
37) import sys
38)
39) parser = OptionParser()
40)
41) default_subject="Simple test message"
42)
43) parser.add_option('-s',
44) '--subject',
45) action="store",
46) type="string",
47) dest="subject",
48) help="The subject",
49) default=default_subject)
50)
51) parser.add_option('-f',
52) '--from',
53) action="store",
54) type="string",
55) dest="author",
56) help="The sender email",
57) default="author@example.com")
58)
59) parser.add_option('-t',
60) '--to',
61) action="store",
62) type="string",
63) dest="to",
64) help="The recipient email",
65) default="recipient@example.com")
66)
67) parser.add_option('-c',
68) '--content',
69) action="store",
70) type="string",
71) dest="content",
72) help="The content",
73) default="This is the body of the message.")
74)
75) parser.add_option('-H',
76) '--host',
77) action="store",
78) type="string",
79) dest="host",
80) help="The SMTP host",
81) default="127.0.0.1")
82)
83) parser.add_option('-p',
84) '--port',
85) action="store",
86) type="string",
87) dest="port",
88) help="The SMTP port",
89) default=None)
90)
91) parser.add_option('-S',
92) '--ssl',
93) action="store_true",
94) dest="ssl",
95) help="SMTP Over SSL (SMTPS)",
96) default=False)
97)
98) parser.add_option('-T',
99) '--starttls',
100) action="store_true",
101) dest="starttls",
102) help="Use STARTTLS",
103) default=False)
104)
105) parser.add_option('-U',
106) '--user',
107) action="store",
108) type="string",
109) dest="user",
110) help="SMTP Auth - User login",
111) default=None)
112)
113) parser.add_option('-P',
114) '--password',
115) action="store",
116) type="string",
117) dest="password",
118) help="SMTP Auth - User password",
119) default=None)
120)
121) parser.add_option('-a',
122) '--attachement',
123) action="append",
124) type="string",
125) dest="attach",
126) help="The attachment(s) file(s) path",
127) default=None)
128)
129) parser.add_option('-d',
130) '--debug',
131) action="store_true",
132) dest="debug")
133)
134) parser.add_option('-v',
135) '--verbose',
136) action="store_true",
137) dest="verbose")
138)
139) parser.add_option('--spam',
140) action="store_true",
141) dest="spam")
142)
143) parser.add_option('--virus',
144) action="store_true",
145) dest="virus")
146)
147)
148) (options, args) = parser.parse_args()
149)
150) if options.spam:
151) if options.subject == default_subject:
152) options.subject = "Test spam message"
153) options.content="""This is the GTUBE, the
154) Generic
155) Test for
156) Unsolicited
157) Bulk
158) Email
159)
160) If your spam filter supports it, the GTUBE provides a test by which you
161) can verify that the filter is installed correctly and is detecting incoming
162) spam. You can send yourself a test mail containing the following string of
163) characters (in upper case and with no white spaces and line breaks):
164)
165) XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X
166)
167) You should send this test mail from an account outside of your network."""
168) elif options.virus:
169) if options.subject == default_subject:
170) options.subject = "Test virus message"
|