Proxy Server

Steve Holden sholden at
Mon Jul 30 09:58:25 EDT 2001

"mixo" <mixo at> wrote in message
news:3B6513A6.C4B84218 at
> How does one  connect to an external mail server when  you actually
> connect to the outside through a proxy server (which may or may not
> require a user id  and or a password)? What I want to be able to do
> is , given an email address, get the  mail host ,and using that host,
> verify
> that the email receipient exists before sending mail using "smtplib".
Seems to me the point of the proxy is precisely to stop systems from
connecting to port 25 on anything but the mail proxy host. You will almost
certainly find (if your net admins have done their job properly and the
situation is correctly described) that you cannot use smtplib to connect to
anything other than your mail proxy host. Certainly nothing outside your
firewall, anyway.

In the case where no firewall is installed the correct procedure is to
separate out the domain from the email address (that will be everything
following the "@") and use the DNS to look up the domain's mail hosts by
retrieving the MX records, then trying each mail host, in order of
increasing numerical priority, until you get a response or the list is
exhausted. In the latter case you could try using the domain itself as a
last-resort mail exchanger, but this will usually fail.

I have written code to do precisely this, to allow a client to send email
billing statements on behalf of their agents. I'm not sure I want to publish
the code, however, given its ability to skip around the normal "no
forwarding" rules imposed by most sensible mail hosts. This, by the way, is
one reason you are being forced to work through a mail proxy: in combination
with the firewall it stops you from spamming external domains with traffic
purporting to come from some other domain which is not a part of your own.

don't-shoot-the-messenger-ly y'rs  - steve

More information about the Python-list mailing list