How to send a mail by communicating directly with an SMTP server in telnet?

0

3

How to communicate with an SMTP server with telnet, in order to send a mail?

 telnet smtp.something.somewhere 53 Trying
 10.xxx.xxx.xxx... 
 Connected to smtp.something.somewhere.
 Escape character is '^]'.

And that is as far as I got. What do I have to do after?

What do I have to write after "HELO"?

Abhijeet Rastogi

Posted 2010-01-20T20:13:12.947

Reputation: 2 801

Answers

6

This is a VERY important thing to be able to do and has saved my bacon on several occasions!

So FOOEY to all those who voted down this question! PLEASE NOTE: I'm referring to the technical question, not the motive. Being able to do this is important for testing ones system, for example. Having the system up and therefore able to use an automated web-based open relay testing site is not always possible.

You also said, "I actually want to know how can i do this myself.."

Well, OK, the first thing to point out is that there's an RFC on this one - the official specification, and you can find it and have all the data you need.

Here are some basics:

1) $ telnet **domain.address** 25

(25 is the standard port, but it could be set to something else)

2) EHLO **your.domain** or

HELO **your.domain**

3) MAIL FROM: **your.email@address**

4) RCPT TO: **destination@email.address**

5) **DATA** now you can type your message.

6) You may now, optionally, enter a subject line like this:

**Subject:** whatever your subject line is
**carrage_return**
**carrage_return**

(there is no response to this)

7) When done, end with:

**carrage_return**.**carrage_return**

(In other words, new line, period, new line.)

6) You can now enter a new mail message if it's destined for this same server, or you can exit by entering:

**QUIT**

Richard T

Posted 2010-01-20T20:13:12.947

Reputation: 427

@Richard - the original version of the question was downvoted, check previous edits to know why. The original was not really in a good objective, this is why I changed it a bit for a more general purpose. – Gnoupi – 2010-01-21T09:37:44.890

so, can i actually do this with gmail. Or how can i do it with gmail – Abhijeet Rastogi – 2010-01-21T17:47:47.073

I agree completely that being able to telnet in and test mail is a good basic skill to have, so +1 from me – Jeff Atwood – 2010-01-22T22:03:13.747

Shadyabhi, I have no idea if Google's gmail servers will accept your hand typing or not but I suspect so because it's part of the RFC. However, you should note that in the modern era, most administrators put basic checks in place to help ensure the data entered is valid because when it isn't, the mail is usually spam and everybody wants to filter out as much spam as possible. You can be SURE Google does... Give it a try! RT – Richard T – 2010-01-24T05:03:06.843

4

In general, about sending mails, I recommend you to learn more about the protocol you are using: the SMTP protocol.

If you have time, you should read the RFC documents (links can be found at the previous link) which are describing the entire protocol, which commands are available, and how to use them.

Gnoupi

Posted 2010-01-20T20:13:12.947

Reputation: 7 909

2Might as well point out that open mail relays are basically non-existent thanks to spam. It was a cute trick back in the early 90's. – Satanicpuppy – 2010-01-20T20:41:17.063

@satanicpuppy - Yes, exactly, the question is anyway very naive, we have someone who wants to send a mail, pretending he is someone else, most likely in wrong purposes... but finally, without really knowing a thing about it. I posted this answer to at least teach him a bit about what he was attempting to do, communicating with the smtp server. – Gnoupi – 2010-01-20T21:03:41.550

3

Port 53 is registered for DNS. Perhaps the trouble you are having comes from not using port 25, the registered SMTP port.

eleven81

Posted 2010-01-20T20:13:12.947

Reputation: 12 423