My 2 paisas

Posts Tagged ‘smtp

Postal is used to benchmark SMTP servers.
I am using it so that I can send mails continously to my test server and hence check if it is working properly. Hence this saves me from the pain of composing mails everytime I do some changes in the server and check if the changes I made is what I intended.

All I have to do is execute one command given below.

postal -m 100 -f test -t 5 users_mail

users_mail has the list of all the users in my test server.


HELO handles the basic SMTP commands, EHLO is “Enhanced HELO” and has more

An advanced mailserver will send “EHLO …” — if the remote mailserver
doesn’t accept EHLO, then it will revert to HELO (which all mailservers

Tags: , ,

After you have set-up the connection with any SMTP server using telnet, you can try different commands, and they’ll be processed and responded to with numeric response codes.
These three-digit coded responses, like 220, may look familiar to Webmasters. The first digit indicates success or failure. 1 indicates a success requiring confirmation, 2 indicates complete success, and 3 indicates success so far, but that more input is expected. 4, the first failure code, is used for failures that may be temporary, such as the mail account existing but being locked; 5 indicates that the failure condition is permanent, such as a syntax error in the command. The second and third digits provide further details, but at the top level, all that matters is that 1xx, 2xx, and 3xx are good, and 4xx and 5xx indicate problems. (For further information on mail response codes, read RFC 1893.)

Tags: ,
  • Coutsey to Bob Peers>
  • Sending emails using telnet.

    The basics.

    Before starting it’s important to know a few things:

    SMTP address.

    The SMTP server address of a provider you are permitted to use. Usually this will be you ISP’s SMTP server but could be any other, if you are not sure of the address
    then look at the settings in your email client. Otherwise the site has a long
    list of SMTP servers.

    Port blocking.

    To prevent spamming it’s possible that your ISP blocks the default SMTP port, port 25. If this is the case and you try to connect to a different SMTP server (other
    than your ISP’s smtp server) then you will probably just get a timeout when you try to connect. Some email providers allow you to use an alternate port, in my
    case I use and they allow you to use port 26, but you will have to check with your
    account provider first.


    If you are able to connect to another SMTP that’s not your ISP’s then you will (or should) only be able to send an email to a user of that email provider. For example I can
    connect using telnet to my email provider at and send an email to another Fastmail user since they have to accept mail to their users (otherwise they would
    not be able to receive any mail), but if I try to send an email to another email address, say then I will be denied since then I’m using’s
    SMTP server as a mail relay which is not allowed without authentication.

    Using telnet.

    If you make a mistake you cannot use backspace to delete the entry, you may have to press enter to get an error and then re-type the command or quit and start again.

    Connecting to the host.

    With this in mind it’s very easy to send a basic text email just using telnet which is installed on most computers. First open up a terminal and type the following, of
    course replacing with the address of your SMTP server:

    telnet 25

    This should return something like:

    telnet 25
    Connected to (
    Escape character is '^]'.
    220 ESMTP Postfix (Debian/GNU)

    HELO command.

    Next we need to introduce ourselves using the helo command, in reality this can be anything and the mail will still be sent OK (although a false helo command
    will result in a spam score from spamassasin for example).

    helo mail.localhost

    MAIL FROM command.

    Next we type mail from: followed by your email address, if you use a name as well then you need to put angle brackets around you address,
    like Bob Peers <>, but the name is not necessary

    250 Ok

    RCPT TO command.

    Now type rcpt to: followed by who you are sending the mail to, following the same rules as above. Note that this IS NOT the address that appears on the To: line in
    your email client or webmail, the two are completely unrelated which is why you can receive spam when your email address is not listed on the To: line.

    250 Ok

    DATA command.

    Now for the actual mail body, type the word ‘data’ and press enter:

    354 End data with <CR><LF>.<CR><LF>

    Your SMTP server might not display the extra help here but it simply means that we type our mail body now and to end the input press enter then type a single .
    followed by pressing enter again. At this point we can add extra headers if we wish but they are not required. This just shows that the To and From fields are just
    part of the message body and have nothing to do with the delivery of the email. However if you do not add them then the message will arrive with
    ‘To: undisclosed-recipients:; in the To field, which again will probably cause your message to be assigned a spam score. If you do decide to add these extra
    headers make sure you leave a blank line between them and the ‘real’ text you wish to appear in the body of the message.

    to:Joe Bloggs<>
    from: Bob Peers<>
    subject:Telnet test

    Hope you are following along OK...
    250 Ok: queued as 4DDFB180CDA

    To actually send the mail we need to quit the telnet session by typing ‘quit’.

    221 Bye
    Connection closed by foreign host.


    If all goes well you should get the email without problems, that’s basically all there is to it. Many of the extra lines are not really required, as long as you type
    the ‘helo’, ‘mail from:’ and ‘rcpt to:’ commands along with ‘data’, terminating ‘.’ and ‘quit’ the mail should be sent.

    Relay access denied error.

    If you try to send an email to an external address when you are not permitted you will get some output like below (this is using my Fastmail account).

    telnet 25
    Connected to (
    Escape character is '^]'.
    220 ESMTP . No UCE permitted.
    helo mail.localhost
    250 Ok
    554 <>: Relay access denied
    221 Bye
    Connection closed by foreign host.
    Tags: ,

    Links that I liked to save

    Blog Stats

    • 45,501 hits