Commit ba077555 authored by ale's avatar ale

Add a sendmail script that talks to a remote SMTP server

parent 4b742ffc
Pipeline #3267 passed with stages
in 1 minute and 52 seconds
......@@ -4,6 +4,7 @@ COPY conf /tmp/conf
COPY build.sh /tmp/build.sh
COPY start.sh /start.sh
COPY apply-forced-params /usr/local/bin/apply-forced-params
COPY sendmail.py /usr/sbin/sendmail
RUN /tmp/build.sh && rm -fr /tmp/build.sh /tmp/conf
ENTRYPOINT ["/usr/local/bin/chaperone"]
#!/usr/bin/python
#
# Send an email sent from stdin using a remote SMTP server.
# Behaves similarly to /usr/sbin/sendmail (sort of).
#
import optparse
import sys
import smtplib
parser = optparse.OptionParser()
parser.add_option('-i', dest='ignored', action='sore_true')
parser.add_option('-f', dest='from_addr', default='nobody')
parser.add_option('--server', dest='server', default='localhost')
parser.add_option('--port', dest='server_port', type='int', default=25)
opts, args = parser.parse_args()
if not args:
raise Exception('Not enough arguments')
msg = sys.stdin.read()
s = smtplib.SMTP(opts.server, opts.server_port)
s.sendmail(opts.from_addr, args, msg)
s.quit()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment