dig yourdomain.com mx | SMTP commands (HELO, EHLO, MAIL FROM, RCPT TO, DATA, RSET, VRFY, NOOP, QUIT)
Gmail requires TLS to relay mail on your behalf. This type of connection is necessary when your desktop or mobile e-mail client is sending mail from your Gmail account.
However, any normal mail server will still accept a message to a recipient on that server without using TLS or any kind of authentication. For example, you can connect to
gmail-smtp-in.l.google.com
on port 25 and conduct an unencrypted SMTP session.
Assuming that you are me@mydomain.com, you are logged into your mail server mail.mydomain.com, and you are sending a message to you@yourdomain.com, it looks like this:
dig yourdomain.com
mx
and note the results (let's say it's mail001.yourdomain.com)telnet mail001.yourdomain.com 25
- Deliver a message:
HELO mail.mydomain.com
MAIL FROM: me@mydomain.com
RCPT TO: you@yourdomain.com
RCPT TO: yourmom@yourdomain.com
DATA
From: "Mehrdad" <me@mydomain.com>
To: "Enrique Peñalosa" <you@yourdomain.com>
Cc: "Gabriela Peñalosa" <yourmom@yourcomain.com>
Date: Fri, 30 Sep 2011 11:21:19 -0700
Subject: Thanks for all the fish!
It was a wonderful picnic. I really enjoyed the salmon burgers.
See you next week,
Mehrdad
.
You issued the
HELO
command to your SMTP server. This tells it that you want to use the original SMTP commands. STARTTLS
is not one of these commands, thus you should not be able to use STARTTLS
.
The first step in resolving this is to switch from the
HELO
command to the EHLO
command. When you do, you will see that the SMTP server responds with the set of SMTP extensions that it supports. Hopefully, STARTTLS
will be listed.
Here's a conversation with GMail's SMTP server:
CLIENT: EHLO me.example.com
SERVER: 250-mx.google.com at your service
SERVER: 250-SIZE 35882577
SERVER: 250-8BITMIME
SERVER: 250-STARTTLS
SERVER: 250 ENHANCEDSTATUSCODES
CLIENT: STARTTLS
SERVER: 220 2.0.0 Ready to start TLS
<negotiation begins here...>
Basic SMTP Commands
Below are the basic SMTP commands described. All SMTP servers that follows the SMTP protocol specification must support these basic commands. HELO (Hello)The client sends this command to the SMTP server to identify itself and initiate the SMTP conversation. The domain name or IP address of the SMTP client is usually sent as an argument together with the command (e.g. “HELO client.example.com”). If a domain name is used as an argument with the HELO command, it must be a fully qualified domain name (also called FQDN). MAIL FROMSpecifies the e-mail address of the sender. This command also tells the SMTP server that a new mail transaction is starting and makes the server to reset all its state tables and buffers etc. This command is usually sent as the first command after the identifying and login process. If the senders e-mail address is accepted the server will reply with a 250 OK reply code. Example:
C: MAIL FROM:<mail@samlogic.com> S: 250 OK |
C: MAIL FROM:<mail@samlogic.com> S: 250 OK C: RCPT TO:<john@mail.com> S: 250 OK C: RCPT TO:<peggy@mail.com> S: 250 OK |
DATAThe DATA command starts the transfer of the message contents (body text, attachments etc). After that the DATA command has been sent to the server from the client, the server will respond with a 354 reply code. After that, the message contents can be transferred to the server. When all message contents have been sent, a single dot (“.”) must be sent in a line by itself. If the message is accepted for delivery, the SMTP server will response with a 250 reply code. Example (the message contents is set to italic in the example below):
C: DATA S: 354 Send message content; end with <CRLF>.<CRLF> C: Date: Thu, 21 May 2008 05:33:29 -0700 C: From: SamLogic <mail@samlogic.com> C: Subject: The Next Meeting C: To: john@mail.com C: C: Hi John, C: The next meeting will be on Friday. C: /Anna. C: . S: 250 OK |
Example - How To Use Basic SMTP Commands The example below shows how some of the basic SMTP commands described in this page can be used to send an e-mail message trough an SMTP server to a recipient.
S: 220 smtp.server.com Simple Mail Transfer Service Ready C: HELO client.example.com S: 250 Hello client.example.com C: MAIL FROM:<mail@samlogic.com> S: 250 OK C: RCPT TO:<john@mail.com> S: 250 OK C: DATA S: 354 Send message content; end with <CRLF>.<CRLF> C: <The message data (body text, subject, e-mail header, attachments etc) is sent> C: . S: 250 OK, message accepted for delivery: queued as 12345 C: QUIT S: 221 Bye |
Part 2: |
If a client initiates the SMTP communication using an EHLO (Extended Hello) command instead of the HELO command some additional SMTP commands are often available. They are often referred to as Extended SMTP (ESMTP) commands or SMTP service extensions. Every server can have its own set of extended SMTP commands. After the client has sent the EHLO command to the server, the server often sends a list of available ESMTP commands back to the client. EHLO (Extended Hello)Same as HELO but tells the server that the client may want to use the Extended SMTP (ESMTP) protocol instead. EHLO can be used although you will not use any ESMTP command. And servers that do not offer any additional ESMTP commands will normally at least recognize the EHLO command and reply in a proper way. AUTH (Authentication)The AUTH command is used to authenticate the client to the server. The AUTH command sends the clients username and password to the e-mail server. AUTH can be combined with some other keywords as PLAIN, LOGIN and CRAM-MD5 (e.g. AUTH LOGIN) to use different login methods and different levels of security. The example below shows how AUTH LOGIN can be used to make an authenticated login:
S: 220 smtp.server.com Simple Mail Transfer Service Ready C: EHLO client.example.com S: 250-smtp.server.com Hello client.example.com S: 250-SIZE 1000000 S: 250 AUTH LOGIN PLAIN CRAM-MD5 C: AUTH LOGIN S: 334 VXNlcm5hbWU6 C: adlxdkej S: 334 UGFzc3dvcmQ6 C: lkujsefxlj S: 235 2.7.0 Authentication successful |
S: 220 smtp.server.com Simple Mail Transfer Service Ready C: EHLO client.example.com S: 250-smtp.server.com Hello client.example.com S: 250-SIZE 1000000 S: 250-AUTH LOGIN PLAIN CRAM-MD5 S: 250-STARTTLS S: 250 HELP C: STARTTLS S: 220 TLS go aheadC: EHLO client.example.com * S: 250-smtp.server.com Hello client.example.com S: 250-SIZE 1000000 S: 250-AUTH LOGIN PLAIN CRAM-MD5 S: 250 HELP C: AUTH LOGIN S: 334 VXNlcm5hbWU6 C: adlxdkej S: 334 UGFzc3dvcmQ6 C: lkujsefxlj S: 235 2.7.0 Authentication successful C: MAIL FROM:<mail@samlogic.com> S: 250 OK C: RCPT TO:<john@mail.com> S: 250 OK C: DATA S: 354 Send message, end with a "." on a line by itself C: <The message data (body text, subject, e-mail header, attachments etc) is sent> S . S: 250 OK, message accepted for delivery: queued as 12345 C: QUIT S: 221 Bye |
S: 250 SIZE 1000000 C: MAIL FROM:<mail@samlogic.com> SIZE=500000 |
Comments
Post a Comment