Home > ABAP > ABAP and Email – SMTP Protocol

ABAP and Email – SMTP Protocol

December 28th, 2009 Leave a comment Go to comments

Actually, this post has nothing to do with the ABAP. It will make a brief introduction to SMTP protocol. If you have already familiar with this, please just skip it. We will discuss ABAP in next post.

 Introduction

Simple Mail Transfer Protocol (SMTP) is an Internet standard for electronic mail (e-mail) transmission across Internet Protocol (IP) networks and is the protocol in widespread use today. SMTP is specified for outgoing mail transport and uses TCP port 25. 

SMTP is a relatively simple, text-based protocol, in which a mail sender communicates with a mail receiver by issuing simple command strings and supplying necessary data over a reliable ordered data stream channel, typically a Transmission Control Protocol (TCP) connection. An SMTP session consists of a series of commands, initiated by the SMTP client, and responses from the SMTP server through which the session is opened, operating parameters are exchanged, the recipients are specified, and possibly verified, and the message is transmitted, before the session is closed. The originating host is either an end-user’s email client also known as mail user agent (MUA), or a relay server’s mail transfer agent (MTA).

SMTP Transport Example

Below diagram shows how emails are transported in the Internet using SMTP protocol.

mailserver

 

A typical example of sending a message via SMTP to two mailboxes (alice and theboss) located in the same mail domain (example.com) is reproduced in the following session exchange.

After the message sender (SMTP client) establishes a reliable communications channel to the message receiver (SMTP server), the session is opened with a greeting by the server, usually containing its fully qualified domain name, in this case smtp.example.com. The client initiates its dialog by responding with a HELO command identifying itself in the command’s parameter.

S: 220 smtp.example.com ESMTP Postfix
C: HELO relay.example.org
S: 250 Hello relay.example.org, I am glad to meet you
C: MAIL FROM:
S: 250 Ok
C: RCPT TO:
S: 250 Ok
C: RCPT TO:
S: 250 Ok
C: DATA
S: 354 End data with .
C: From: "Bob Example"
C: To: Alice Example
C: Cc: theboss@example.com
C: Date: Tue, 15 Jan 2008 16:02:43 -0500
C: Subject: Test message
C:
C: Hello Alice.
C: This is a test message with 5 header fields and 4 lines in the message body.
C: Your friend,
C: Bob
C: .
S: 250 Ok: queued as 12345
C: QUIT
S: 221 Bye
{The server closes the connection}

MX Record

A mail exchanger record (MX record) is a type of resource record in the Domain Name System that specifies a mail server responsible for accepting email messages on behalf of a recipient’s domain and a preference value used to prioritize mail delivery if multiple mail servers are available. The set of MX records of a domain name specifies how email should be routed with the Simple Mail Transfer Protocol.

You can easily use a command named nslookup. For example, we want to find the MX record of gmail, here is the step. Go to command line and type command line like “nslookup -q=mx gmail.com”. Below is the result:

 

mxrecord

Summary

In this post, we introduce the SMTP protocol and give an example to show how the client and server communicate with each other. At last, we reveal how the SMTP server find the destination SMTP server address using MX record. In next post, we will find out how the configure SAP system to connect to SMTP server.

  1. Aurelio Figueiredo
    July 15th, 2010 at 07:01 | #1

    Can I configure Gmail in SAP?

  1. December 28th, 2009 at 21:37 | #1