what is the 'host' for SMTP?

Steve R. Hastings steve at hastings.org
Tue May 2 23:42:29 EDT 2006


On Tue, 02 May 2006 22:12:31 -0400, John Salerno wrote:

> If I want to write a cgi script that reads the contents of an HTML form 
> and emails it to me, what would I use as the host parameter for my SMTP 
> instance?

Take a look at your email client.  Find where it specifies the server for
outgoing mail.  Use whatever it says there.

For example, I am a customer of blarg.net; I am therefore permitted to use
mail.blarg.net, which has a mail server running on it.  If your ISP is
example.com, you probably will be using one of these:

mail.example.com
smtp.example.com

But it really could be anything:

norwegianblue.example.com
lovelyplumage.example.com


> The example in the docs is 'localhost', but I don't know what 
> that means or refers to.

"localhost" is a standard UNIX/Linux alias for "my computer's address". 
It will be bound to 127.0.0.1, which is a special, magic address that
can stand in for your computer's actual address.

(Thus the old joke about "hey, try to hack my firewall!  Here's the
address: 127.0.0.1

If someone runs an attack script against that address, they are attacking
their own computer.)

If you  have an SMTP server running on your computer, then you could use
"localhost" and it will work.  Otherwise, not.


> I imagine I would have to use something that 
> was tied to me specifically, but tied to what? My computer? My email 
> address?

SMTP is a protocol.  You can talk SMTP to any computer that has an SMTP
server running.  The standard port number for SMTP is port 25.

These days, most SMTP servers won't just let anyone use them to send email
just anywhere; an SMTP server configured to allow that is called an "open
relay" and spammers love to find them.

If you are using email, then as I said above, your email client should
have an SMTP server filled in already, and you are already using it every
time you send email.  So I suggest you use that.
-- 
Steve R. Hastings    "Vita est"
steve at hastings.org    http://www.blarg.net/~steveha




More information about the Python-list mailing list