Sending EMail via an SMTP Server

DONT SPAM

Email List Servers

Validating and email address before (or without) sending an email

See http://www.ietf.org/ for

Peter L. Berghold says:

The procedure is pretty simple, well at least in concept.
  1. Open a connection to the system with the MTA running on it on TCP port 25. [Ed: or telnet mailserver 25]
  2. Establish who you are with the server using the HELO syntax example:
    The PIC sends--
    HELO picbox1
    

    The MTA replies with--

    250 mailrelay.mydomain.tld Hello picbox1.mydomain.tld Pleased to meet you
  3. Establish who you are sending mail from
    The PIC sends --
    mail from: picbox@mydomain.tld
    

    The MTA replies with --

    250 picbox@mydomain.tld... sender ok
  4. Establish who is to get the mail
    The PIC sends --
    rcpt to: someone@domain.tld
    

    The MTA replies with --

    250 someone@domain.tld... Recipient ok
  5. Now you want to send a message body.
    The PIC sends ---
    data
    

    The MTA replies with --

    354 Enter mail, end with "." on a line by itself
  6. Now you can actually compose the mail. If you want the sender, and a subject to appear on the recipient's mail program's display you need to have your first two lines be:
    From: Pic Program
    Subject: Overtemp in the engine room. Warp drive meltdown imminent.
    

    (I couldn't resist the StarTrek reference! <VBG>)

  7. You want a blank line between the subject line and the body of the text so the recipient's mail program will properly parse out the headers. Another thing is if you are going to generate HTML mail you want to have right after the Subject: line a line reading "Content-Type: text/html" There are other MIME types that you can specify, but I'm not going into the complicated subject of MIME encoding standards, headers, parsing and all that.
  8. Once the body of your message is done you terminate the message with a line with a "." all by its lonesome just as the reply above tells you to. When you do you will get a reply back from the MTA
    250 UAA01680 Message accepted.
    

    The portion UAA01580 is a queue ID that you can possibly use later on for auditing purposes, but I leave that up to other imaginations.

See also:

Connecting to remote mail server via telnet <domain> 25 for anonymous test ... replace <domain> with the domain name of the mailserver. replace <ip> with the IP address of the mail server

<<< 220 ...
>>> HELO rr.com
<<< 250 proxyplus.universe
Relay test 1
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@rr.com>
<<< 250 OK <spamtest@rr.com>
>>> RCPT TO:<fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 2
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest>
<<< 250 OK <spamtest>
>>> RCPT TO:<fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 3
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<>
<<< 250 OK <>
>>> RCPT TO:<fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 4
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 5
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@[<IP>]>
<<< 250 OK <spamtest@[<IP>]>
>>> RCPT TO:<fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 6
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<fakerelaytest%rr.com@<domain>>
<<< 550 Relaying disabled
Relay test 7
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<fakerelaytest%rr.com@<domain>>
<<< 550 Relaying disabled
Relay test 8
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<"fakerelaytest@rr.com">
<<< 550 Relaying disabled
Relay test 9
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<"fakerelaytest%rr.com">
<<< 550 Relaying disabled
Relay test 10
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<fakerelaytest@rr.com@<domain>>
<<< 550 Relaying disabled
Relay test 11
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@dt0b0nf0.san.rr.com>
<<< 250 OK <spamtest@dt0b0nf0.san.rr.com>
>>> RCPT TO:<"fakerelaytest@rr.com"@dt0b0nf0.san.rr.com>
<<< 550 Relaying disabled
Relay test 12
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<fakerelaytest@rr.com@<domain>>
<<< 550 Relaying disabled
Relay test 13
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<@<domain>:fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 14
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<@<domain>:fakerelaytest@rr.com>
<<< 550 Relaying disabled
Relay test 15
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@>
<<< 250 OK <spamtest@>
>>> RCPT TO:<fakerelaytest@rr.com@>
<<< 550 Relaying disabled
Relay test 16
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<rr.com!fakerelaytest>
<<< 550 Relaying disabled
Relay test 17
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<rr.com!fakerelaytest@<domain>>
<<< 550 Relaying disabled
Relay test 18
>>> RSET
<<< 250 Reset state
>>> MAIL FROM:<spamtest@<domain>>
<<< 250 OK <spamtest@<domain>>
>>> RCPT TO:<rr.com!fakerelaytest@<domain>>
<<< 550 Relaying disabled

see also:

Comments: