user-avatar
Today is Monday
May 6, 2024

Tag: smtp

November 10, 2009

Postal to the rescue.

by viggy — Categories: tech — Tags: , , , Leave a comment

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 192.168.31.100 users_mail

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

October 1, 2009

difference between helo and ehlo

by viggy — Categories: Uncategorized — Tags: , , Leave a comment

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

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

October 1, 2009

SMTP numeric codes

by viggy — Categories: Uncategorized — Tags: , Leave a comment

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.)

June 25, 2009

Sending emails using telnet

by viggy — Categories: Uncategorized — Tags: , Leave a comment
  • 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 E-Eeasy.com 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 Fastmail.fm and they allow you to use port 26, but you will have to check with your
    account provider first.

    Relaying.

    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 Fastmail.fm 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 someone@hotmail.com then I will be denied since then I’m using Fastmail.fm’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 mail.yourserver.dk with the address of your SMTP server:

    telnet mail.yoursever.dk 25

    This should return something like:

    telnet mail.yoursever.dk 25
    Trying 172.16.0.2...
    Connected to mail.yoursever.dk (172.16.0.2).
    Escape character is '^]'.
    220 cirkeline.yoursever.dk 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
    250 mail.yoursever.dk

    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 <email@domain.dk>, but the name is not necessary

    mail from:me@domain.dk
    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.

    rcpt to:you@domain.com
    250 Ok

    DATA command.

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

    data
    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<you@domain.com>
    from: Bob Peers<me@domain.dk>
    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’.

    quit
    221 Bye
    Connection closed by foreign host.

    Summary

    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 mail.messagingengine.com 25
    Trying 66.111.4.160...
    Connected to mail.messagingengine.com (66.111.4.160).
    Escape character is '^]'.
    220 frontend2.messagingengine.com ESMTP . No UCE permitted.
    helo mail.localhost
    250 frontend2.messagingengine.com
    mail from:someone@somewhere.dk
    250 Ok
    rcpt to:someoneelse@hotmail.com
    554 <someoneelse@hotmail.com>: Relay access denied
    quit
    221 Bye
    Connection closed by foreign host.