Following up on from my previous post about using telnet to check your email, here’s how you can use telnet to send an email.
There is one very important difference between checking your email and sending an email. Due to the huge amount of spam being sent every day, most ISP’s require that you use their email server to send email. So before you can send an email, you’ll need the name of your ISP’s SMTP server. If you don’t know it, and you’re using either Linux or MacOS X, you can use the nslookup command line utility to find it. Here’s how:
- Open a command prompt,
- Type
nslookup, and hit enter, - Type
set querytype=mx, followed by enter, - Type the domain name for your isp, i.e., isp.net, hit enter.
nslookupwill return the mail exchanger address for your isp,- Type
exitto quitnslookup.
If you don’t have access to nslookup you may be able to guess it from the ISP’s domain name. Taking the ISP domain name to be isp.net:
- mail.isp.net
- smtp.isp.net
Now that you have the SMTP server address, you can start sending email. Back to your command prompt and run the following command:
telnet mail.isp.net 25
Once you have connected to the SMTP server, you’ll need to tell it who you are, so type:
helo localhost
You should get a response similar to:
250 mail.isp.net helo localhost [Your IP Address]
Unlike sending email, you don’t need a username and password to login. The next step is to tell the server the email address you’re sending from:
mail from:[Your Email Address]
If the address is accepted by the server you should see:
250 OK
Now tell it the address that you want to email:
rcpt to:[Recipients Email Address]
Once again, if the address is accepted the server will tell you with:
250 Accepted
Now it’s time to start writing your email. You tell the server that you’re ready with this command:
data
All going well, the server will respond with:
354 Enter message, ending with "." on a line by itself
Before you can write the actual message content, you need to provide a couple of headers for the email. Not including some basic headers could result in your email being classified as spam, resulting in it being rejected by the recipient. The basic headers to include are Date, From, To, and Subject, as follows:
Date: [Todays Date & Time]
From: [Your Email Address]
To: [Recipients Email Address]
Subject: [Your Email Subject]
Just before starting the content of your email, hit enter to leave a blank line, then start typing!
When you are finished writing your email, hit enter to leave a blank line, type a “.” (no quotes), and hit enter a again. The server should respond with:
250 OK [Message ID]
And that’s it, your message will be queued by the email server and sent on to your recipient.
[...] you want to send an email, then a different protocol must be used: SMTP, and that’s another post. Share and Enjoy: Share This [...]
This example works if no smtp authentication is enabled. Do you know how to send an e-mail using telnet if POP before SMTP authentification is enabled?
SMTP Authentication is specified in RFC 4954:
http://tools.ietf.org/html/rfc4954
According to the RFC, authentication is achived by a BASE64 challenge response. Unless you can issue the relevant response in BASE64 on the fly, you probably won’t be able to send mail where SMTP Authentication is being used.
Regards,
Paul.
do u know how to send mail where SMTP Authentication is being used.
SMTP-AUTH is discussed in RFC’s 2554 and 4954, which can be found here:
http://www.faqs.org/rfcs/rfc2554.html
http://tools.ietf.org/html/rfc4954
The ability to use SMTP AUTH requires a password challenge-response between the server and client. The password is encoded using base64.
More information on SMTP-AUTH from Wikipedia:
http://en.wikipedia.org/wiki/SMTP-AUTH
With examples of the login process here:
http://www.technoids.org/saslmech.html
Thanks for this… I have been looking forever to see if you could add:
Date: [Todays Date & Time]
From: [Your Email Address]
To: [Recipients Email Address]
Subject: [Your Email Subject]
and where to put them. This is definitely the most complete instructions I have found! Thanks
Cheers Pat, glad this helped!