what is the 'host' for SMTP?

J

John Salerno

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? The example in the docs is 'localhost', but I don't know what
that means or refers to. I imagine I would have to use something that
was tied to me specifically, but tied to what? My computer? My email
address?
 
S

Steve R. Hastings

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.
 
D

Dennis Lee Bieber

If you've a gmail account, you can set it as smtp.gmail.com.

He's mentioned having the mail sent from a CGI script, so the
"computer" would be the web server... I'd hope his hosting provider has
a mail server available (with luck even on the same server, so
"localhost" would work -- and configured to assume any email submitted
by itself is a valid user).
--
Wulfraed Dennis Lee Bieber KD6MOG
(e-mail address removed) (e-mail address removed)
HTTP://wlfraed.home.netcom.com/
(Bestiaria Support Staff: (e-mail address removed))
HTTP://www.bestiaria.com/
 
J

John Salerno

Steve said:
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

Thanks for all the information. Very helpful. But I'm still a little
confused, because it seems like that's not enough information. If all I
put in is, for example, smtp.gmail.com, how is that directed to my own
email address? Do I still need to include other, more specific (i.e.
personal) information elsewhere?
 
S

Steve R. Hastings

If all I
put in is, for example, smtp.gmail.com, how is that directed to my own
email address?

The address of the SMTP server does not specify where the email will go.
SMTP is a protocol, and when you are talking SMTP to the server, part of
what the conversation includes will be to whom you wish to send the email.

Please Google for information on SMTP. You can also start here:

http://en.wikipedia.org/wiki/SMTP
 
J

John Salerno

Steve said:
The address of the SMTP server does not specify where the email will go.
SMTP is a protocol, and when you are talking SMTP to the server, part of
what the conversation includes will be to whom you wish to send the email.

Please Google for information on SMTP. You can also start here:

http://en.wikipedia.org/wiki/SMTP

Thanks, I'll give it a look.
 
M

Marco Carvalho

Uh, I don't sent to list :p

---------- Forwarded message ----------
From: Marco Carvalho <[email protected]>
Date: May 4, 2006 12:45 AM
Subject: Re: what is the 'host' for SMTP?
To: John Salerno <[email protected]>


Steve R. Hastings wrote:

Thanks for all the information. Very helpful. But I'm still a little
confused, because it seems like that's not enough information. If all I
put in is, for example, smtp.gmail.com, how is that directed to my own
email address? Do I still need to include other, more specific (i.e.
personal) information elsewhere?

You need a little more than a smtp server address to send an e-mail.

If you are using smtplib:

import smtplib
sender = "(e-mail address removed)"
to = "(e-mail address removed)"
message = "blablabla"
smtplogin = "your_login_on_gmail"
smtppasswd = "your_password_on_gmail"
smtpserver = "smtp.gmail.com"

smtp = smtplib.SMTP(smtpserver)
smtp.login(smtplogin,smtppasswd)
smtp.sendmail(sender, to, message)
smtp.quit()

I don't put the correct construction of the message's headers and
body, it's another story :)

--
Marco Carvalho (macs) | marcoacarvalho(a)gmail.com
http://arrakis.no-ip.info | http://cdd.debian-br.org
Maceio - Alagoas - Brazil
Debian GNU/Linux unstable (Sid)
GNU-PG ID:08D82127 - Linux Registered User #141545
Notícias Semanais do Debian em Português: http://www.debian.org/News/weekly
Alertas de Segurança Debian (DSA): http://www.debian.org/security


--
Marco Carvalho (macs) | marcoacarvalho(a)gmail.com
http://arrakis.no-ip.info | http://cdd.debian-br.org
Maceio - Alagoas - Brazil
Debian GNU/Linux unstable (Sid)
GNU-PG ID:08D82127 - Linux Registered User #141545
Notícias Semanais do Debian em Português: http://www.debian.org/News/weekly
Alertas de Segurança Debian (DSA): http://www.debian.org/security
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,294
Messages
2,571,511
Members
48,206
Latest member
EpifaniaMc

Latest Threads

Top