Today, folks, I am going to share a very enriching experience of sending mail through SMTP protocol without a mail client. Just as always, first some basic stuff, you will need to understand. Simple Mail Transfer Protocol (SMTP) is used by both mail clients sending mail to server and by mail servers exchanging mail between each other. Basically it is a language that everyone on the Net uses to send mail. The interesting part is that most of the time it is hidden from us and is done by all kinds of software. However, using Telnet we can take a trip to the forbidden world of Internet backstage. Telnet or Teletype Network is used to provide an interactive communications facility. Sounds pretty heavy, but basically it is just a tool that looks like a command line. We will access this tool with the help of Putty - one of our best friends. Putty is just a free software that allows us to use Telnet and many other interesting things on our journey around the Web.
Things You Will Need
- Putty (free);
- knowledge about your SMTP mail server and its active port (usually 25 or 1025, but there may be exclusions).
In the Putty type:
telnet smtp.domain.tld 1025
where telnet is just a small notification for Putty that you want to use Telnet protocol, mail.domain.tld is your SMTP server and 1025 is the port that SMTP uses, sometimes you will be also able to use port 25 that also is attributed to SMTP (if your provider gives same IP address for mail.domail.tld, smtp.domail.tld, pop.domail.tld and imap.domail.tld, then you can use any of those domains, but be carefull to state the correct port number at the end). As a result you will receive:
telnet smtp.domain.tld 1025
Connected to smtp.domain.tld.
Escape character is '^]'.
220 mail176c2.mailservers.com ESMTP Sendmail 8.13.6/8.13.1; Tue, 22 Dec 2009 11:04:14 -0500
Now as a really polite person you should say "Hi!". The funny thing is that all mail servers seem to be a bit too geeky and do not recognize normal greetings. They all need to be treated in a special way: instead of saying hi or hello, you must type:
yep, with only one "l". Call it a whim, but you have to do it this way, or there will be no conversation. If you have made the "correct" mistake, then you will see:
250 mail176c2.mailservers.com Hello [XXX.XXX.XXX.XXX], pleased to meet you
That is so nice of a server to greet us :-)
With [XXX.XXX.XXX.XXX] I have humbly masked my IP address.
After all the formalities are behind, the next step is to make-up a letter. Type:
mail from: firstname.lastname@example.org
if such a mail server exists, the server will answer:
250 2.1.0 email@example.com... Sender ok
Then you can type:
rcpt to: firstname.lastname@example.org
Yet again, if the server thinks that the recipient e-mail is ok, you will get this:
250 2.1.5 email@example.com... Recipient ok
Now all that is left is simply to make up a new letter. Type:
subject: Hello, my friend!
250 2.0.0 nBMG4Ew8005562 Message accepted for delivery
DATA means that from now on you type the message. After the "subject:" you must insert your subject (what a surprise) and on the next line the server expects to see the body of the message. "250 2.0.0 nBMG4Ew8005562 Message accepted for delivery" means that all is OK and that the message will be sent
That was not so hard, was that? I hope you enjoyed reading this how-to just as much as I did writing it.
See you and have lots of fun!
Tips & Warnings
You should use only your e-mail addresses that are hosted at the mail server you are connecting to in the "mail from:" field. Putting wrong email is called spoofing and is one of the forms of spam.