Walker News

Uses Telnet And SMTP Commands To Send Email With Subject And HTML Content

The following example using telnet on RHEL5.2 to connect Microsoft Exchange ESMTP (Enhanced SMTP) at port 25 and execute SMTP commands to send email with subject and HTML content.

The SMTP/ESMTP commands reference is useful for software developer who want to add simple email alert feature to a program, i.e. using network socket programming to establish connection to SMTP server and execute the SMTP commands.

At Linux command prompt, run telnet to connect SMTP server at port 25. For example:
telnet smtp.hqexch1.com 25

Now, we are at the telnet-SMTP command prompt (SMTP commands are written in capital case; replace whichever command input to those of yours):
  1. EHLO – the ESMTP style of saying “helo”.
  2. MAIL FROM:alert@walkernews.net – to specify sender’s email address.
  3. RCPT TO:recipient1@exchmail.com – to specify recipient’s email address (for the “To:” field).
  4. DATA – to signal starts of email body.
  5. The following specify CC list, email subject and HTML content:
    SUBJECT: Hello World!
    MIME-Version: 1.0
    Content-Type: text/html; charset="ISO-8859-1"
    <meta http-equiv='content-type' content='text/html; charset=ISO-8859-1'>
    <style type='text/css'>
    #WN {font-weight:bold;color:#F00;font-weight:bold;}
    <p id="WN">HELLO WORLD</p>
  6. Type . (period or dot) to signal end of email body.
  7. quit to exit telnet-SMTP connection.

On Microsoft Outlook that connect to the said Microsoft Exchange server, type F9 to activate “send and receive” immediately and check if the email sent by telnet is successful.

Custom Search

  1. Taru Shah 10-08-12@01:24

    The Content-Type: text/html; charset=’ISO-8859-1′” from java is not working it is sitting in telnet window.

2018  •  Privacy Policy