0

I am sending emails using smtplib using internal relay.

        msg['From'] = fromaddr
        msg['To'] = toaddr
        msg['Subject'] = server
        s = smtplib.SMTP('SMTP', port)
        s.send_message(msg)
        s.quit()

Access is controlled with an ACL and I would like to be able to fire my script from my local machine through an intermediary host that is allowed on the SMTP relay. Until now I have been sshing to the intermediary host but that's a bit of a palaver to be honest.

How would I go about tunneling this traffic so SMTP relay would see the request came from intermediary host?

PS. All actions are done within a domain environment. I just want communication to flow from my hostname, through another host that is allowed on our local smtp relay.

qazws
  • 21
  • 4
  • Your ISP (and or others) will probably block SMTP traffic on the regular ports. So you'd have to configure a mail server on an alternate port that you're allowed to send on and use that as a relay host. SMTP has support for this "built in" so all you need would be to configure a mail-server that listens on a non-default port and send your e-mails "as normal" to it, and have it configured to relay any externally going e-mails. Or you could use a proxy: https://stackoverflow.com/questions/5239797/python-smtplib-proxy-support – Torxed May 06 '20 at 09:29
  • sorry, forgot to mention - it works without a problem from the intermediary, the setup is corporate domain and everything happens internally. – qazws May 06 '20 at 09:48

0 Answers0