Simple Mail Transfer Protocol



Similar documents
RFC 821 SIMPLE MAIL TRANSFER PROTOCOL. Jonathan B. Postel. August 1982

CS 164 Winter 2009 Term Project Writing an SMTP server and an SMTP client (Receiver-SMTP and Sender-SMTP) Due & Demo Date (Friday, March 13th)

RFC Simple Mail Transfer Protocol

Mail system components. Electronic Mail MRA MUA MSA MAA. David Byers

CipherMail Gateway Quick Setup Guide

CS43: Computer Networks . Kevin Webb Swarthmore College September 24, 2015

Internet Technology 2/13/2013

Appendix. Web Command Error Codes. Web Command Error Codes

Networking Applications

Category: Experimental August 1995

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET)

Internet Technologies Internet Protocols and Services

Evolution of the WWW. Communication in the WWW. WWW, HTML, URL and HTTP. HTTP - Message Format. The Client/Server model is used:

Evolution of the WWW. Communication in the WWW. WWW, HTML, URL and HTTP. HTTP Abstract Message Format. The Client/Server model is used:

SMTP Servers. Determine if an message should be sent to another machine and automatically send it to that machine using SMTP.

Network Services. SMTP, Internet Message Format. Johann Oberleitner SS 2006

Protocolo FTP. FTP: Active Mode. FTP: Active Mode. FTP: Active Mode. FTP: the file transfer protocol. Separate control, data connections

Internet Security [1] VU Engin Kirda

Understanding SMTP authentication and securing your IBM Lotus Domino 8 server from spam

2- Electronic Mail (SMTP), File Transfer (FTP), & Remote Logging (TELNET)

The Application Layer. CS158a Chris Pollett May 9, 2007.

Applications and Services. DNS (Domain Name System)

SPAMfighter SMTP Anti Spam Server

Workflow Configuration on R12/R11. High Level Steps. SENDMAIL configuration mostly done by System Administrator Workflow configuration for R12

. MIME is the protocol that was devised to allow non-ascii encoded content in an and attached files to an .

For the purpose of service extensions to SMTP, SMTP relays a mail object containing an envelope and a content.

Electronic Mail

FTP and . Computer Networks. FTP: the file transfer protocol

Issue 2EN. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

Remote login (Telnet):

Network Working Group. Category: Informational January Principles of Operation for the TPC.INT Subdomain: Radio Paging -- Technical Procedures

Mail agents. Introduction to Internet Mail. Message format (2) Authenticating senders

Introduction. Friday, June 21, 2002

Cork Institute of Technology Master of Science in Computing in Education National Framework of Qualifications Level 9

Cannot send Autosupport , error message: Unknown User

Chapter 2 Application Layer. Lecture 5 FTP, Mail. Computer Networking: A Top Down Approach

SMTP (Simple Mail Transfer Protocol)

security

. Daniel Zappala. CS 460 Computer Networking Brigham Young University

QMAIL & SMTP: A Secure Application for an Unsecure Protocol. Orr Dunkelman. orrd@vipe.technion.ac.il. January 27, 2004 SMTP and QMAIL Slide 1

The Application Layer: DNS

Introduction to Computer Networks

smtp-user-enum User Documentation

Service for checking whether an is operative or not. Validate ids in your databases.

Internet and Intranet Protocols and Applications

Mail Avenger. David Mazières New York University

Setup Local Mail Server Using Postfix, Dovecot And Squirrelmail On CentOS 6.5/6.4

on the RaQ 3. General. server. Services

Installation Guide For Choic Enterprise Edition

, SNMP, Securing the Web: SSL

Exim4U. Server Solution For Unix And Linux Systems

Application Example: WWW. Communication in the WWW. WWW, HTML, URL and HTTP. Loading of Web Pages. The Client/Server model is used in the WWW

Using WinGate 6 . Concepts, Features, and Configurations.

Chakchai So-In, Ph.D.

Network Working Group. Category: Informational January 1994

Table of Contents. Electronic mail. History of (2) History of (1) history. Basic concepts. Aka (or according to Knuth)

CPSC Network Programming. , FTP, and NAT.

Simple Scan to Setup Guide

Articles Fighting SPAM in Lotus Domino

FTP: the file transfer protocol

Internet Architecture

CSCI-1680 SMTP Chen Avin

smtplib SMTP protocol client

Regions Secure Webmail. Instructions

Computer Networks 1 (Mạng Máy Tính 1) Lectured by: Dr. Phạm Trần Vũ MEng. Nguyễn CaoĐạt

Domain Name System (DNS)

Government of Canada Managed Security Service (GCMSS) Annex A-5: Statement of Work - Antispam

Load Balancing Exchange 2007 SP1 Hub Transport Servers using Windows Network Load Balancing Technology

Category: Experimental February 1996

OPS535 Advanced Network Administration. SMTP Lab SIMPLE MAIL TRANSFER PROTOCOL

Issue 1 EN. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

IBM i. Networking . Version 7.2

Writing for Developers: The New Customers. Amruta Ranade

Hosted CanIt. Roaring Penguin Software Inc. 26 April 2011

Sending via Public Sites Model 5300 Controller

SMTP Best Practices, Configurations and Troubleshooting on Lotus Domino.

Linux MDS Firewall Supplement

XGENPLUS SECURITY FEATURES...

Technical papers How works

Application-layer Protocols and Internet Services

Management CSCU9B2 CSCU9B2 1

Implementing MDaemon as an Security Gateway to Exchange Server

Mail Server Scenarios and Configurations

Using over FleetBroadband

Libra Esva. Whitepaper. Glossary. How Really Works. Security Virtual Appliance. May, It's So Simple...or Is It?

Communication Systems Network Applications - Electronic Mail

Redirecting and modifying SMTP mail with TLS session renegotiation attacks

Linux Administrator (Advance)

The basic groups of components are described below. Fig X- 1 shows the relationship between components on a network.

Troubleshooting IBM Lotus Domino 8 mail routing issues

A New Approach to Enhance Performance Through SMTP Protocol

Mailing System: The Intra Mail

CSI Lab 1 : Exercise Find the IP address of Or, another way:

Nokia for Business. Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation

UserGate Mail Server 2.X Administrator's Manual

Serial Deployment Quick Start Guide

SMTP Status Codes & SMTP Error Codes Reference

TREND MICRO. InterScan VirusWall 6. SMTP Configuration Guide. Integrated virus and spam protection for your Internet gateway.

DATA COMMUNICATOIN NETWORKING

Transcription:

Page 1 of 6 Home : Network Programming Simple Mail Transfer Protocol Contents What is SMTP? Basics of SMTP SMTP Commands Relaying of Messages Time Stamps and Return Path in Message Header Mail Exchangers An example SMTP Transaction using Telnet Further References What is SMTP? SMTP or Simple Mail Transfer Protocol is a way to transfer email reliably and efficiently. SMTP is a relatively simple, text-based protocol, where one or more recipients of a message are specified (and in most cases verified to exist) and then the message text is transferred. You can think of SMTP as the language that mail servers use to communicate among themselves. Since this protocol started out as purely ASCII text-based, it did not deal well with binary files. Standards such as MIME (RFC 2045) were developed to encode binary files for transfer through SMTP. SMTP is used to send mail to the recipient's mailbox. The recipient may use various methods to access the emails in his mailbox. A couple of methods that are very popular are POP3 and IMAP. These protocols allow a user to access his messages stored on a remote mail server. Basics of SMTP When the user wants to send a message to someone, the sender-smtp establishes a two-way transmission channel to a receiver-smtp. SMTP commands are generated by the sender-smtp and sent to the receiver-smtp. SMTP replies are sent from the receiver-smtp to the sender-smtp in response to the commands. In case a direct connection does not exist between the sender and the final destination, the message may be sent via one or more relay SMTP-servers. The relay SMTPservers first act as receivers and then relays the message to the next SMTP. To be able to provide the relay capability the SMTP-server must be supplied with the name of the ultimate destination host as well as the destination mailbox name. Once the transmission channel is established, the SMTP-sender sends a MAIL command indicating the sender of the mail. If the SMTP-receiver can accept mail it responds with an OK reply. The SMTP-sender then sends a RCPT command identifying a recipient of the mail. If the SMTPreceiver can accept mail for that recipient it responds with an OK reply; if not, it responds with a

Page 2 of 6 reply rejecting that recipient (but not the whole mail transaction). The SMTP-sender and SMTPreceiver may negotiate several recipients. When the recipients have been negotiated the SMTPsender sends the mail data, terminating with a special sequence. If the SMTP-receiver successfully processes the mail data it responds with an OK reply. The dialog is purposely lock-step, one-at-atime. SMTP Commands Given below are some basic commands with their brief descriptions. The SMTP standard defines many more commands, most of which are optional to implement. For a detailed study, the user should see RFC 821. HELLO (HELO) This is the first command that is sent when a connection is established. It is used to identify the sender-smtp to the receiver-smtp. The argument field contains the host name of the sender-smtp. HELO <SP> <domain> <CRLF> Note: <SP> stands for a space and <CRLF> stands for a combination of Carriage Return and Linefeed. The receiver-smtp identifies itself to the sender-smtp in the connection greeting reply, and in the response to this command. MAIL (MAIL) There are three steps to SMTP mail transactions. The transaction is started with a MAIL command which gives the sender identification. A series of one or more RCPT commands follows giving the receiver information. Then a DATA command gives the mail data. And finally, the end of mail data indicator confirms the transaction. The first step in the procedure is the MAIL command. The <reverse-path> contains the source mailbox. MAIL <SP> FROM:<reverse-path> <CRLF> If accepted, the receiver-smtp returns a 250 OK reply. The <reverse-path> can contain more than just a mailbox. The <reverse-path> is a reverse source routing list of hosts and source mailbox. The first host in the <reverse-path> should be the host sending this command. RECIPIENT (RCPT) This command gives a forward-path identifying one recipient. If accepted, the receiver-smtp returns a 250 OK reply, and stores the forward-path. If the recipient is unknown the receiver-smtp returns a 550 Failure reply. This second step of the procedure can be repeated any number of times. RCPT <SP> TO:<forward-path> <CRLF>

Page 3 of 6 The <forward-path> can contain more than just a mailbox. The <forward-path> is a source routing list of hosts and the destination mailbox. The first host in the <forwardpath> should be the host receiving this command. DATA (DATA) The third step in the procedure is the DATA command. DATA <CRLF> If accepted, the receiver-smtp returns a 354 Intermediate reply and considers all succeeding lines to be the message text. When the end of text is received and stored the SMTP-receiver sends a 250 OK reply. Since the mail data is sent on the transmission channel the end of the mail data must be indicated so that the command and reply dialog can be resumed. SMTP indicates the end of the mail data by sending a line containing only a period. The mail data includes the memo header items such as Date, Subject, To, Cc, From etc. To see details about possible memo headers and their formats, read RFC 822 - Standard for the format of ARPA Internet text message VERIFY (VRFY) This command asks the receiver to confirm that the argument identifies a user. If it is a user name, the full name of the user (if known) and the fully specified mailbox are returned. VRFY <SP> <user name> <CRLF> RESET (RSET) This command specifies that the current mail transaction is to be aborted. The receiver must send an OK reply. RSET <CRLF> NOOP (NOOP) This command does not affect any parameters or previously entered commands. It specifies no action other than that the receiver send an OK reply. NOOP <CRLF> QUIT (QUIT) This command specifies that the receiver must send an OK reply, and then close the transmission channel. QUIT <CRLF> In order to make SMTP workable, the following minimum implementation is required for all receivers: MAIL

Page 4 of 6 RCPT DATA RSET NOOP QUIT Relaying of Messages The sender specifies the forward-path of the recepient while sending the mail. This forward-path includes not only the address of the recepient but also the route that is to be taken to reach there. This information is useful if there is not direct link betwen the sender and the recepient. The forward-path may be a source route of the form "@ONE,@TWO:VARUN@THREE", where ONE, TWO, and THREE are hosts. ONE is the name of the host who is receiving this command. ONE will forward this message to host TWO. TWO will in turn forward the message to THREE which is the host on which the user VARUN has a mailbox. Conceptually the elements of the forward-path are moved to the reverse-path as the message is relayed from one server-smtp to another. The reverse-path is a reverse source route, (i.e., a source route from the current location of the message to the originator of the message). The reverse-path is used in case a reply has to be sent to the sender. If a server-smtp has accepted the task of relaying the mail and later finds that the forward-path is incorrect or that the mail cannot be delivered for whatever reason, then it must construct an "undeliverable mail" notification message and send it to the originator of the undeliverable mail (as indicated by the reverse-path). Time Stamps and Return Path in Message Header When the receiver-smtp accepts a message either for relaying or for final delivery it inserts at the beginning of the mail data a time stamp line. The time stamp line indicates the identity of the host that sent the message, and the identity of the host that received the message (and is inserting this time stamp), and the date and time the message was received. Relayed messages will have multiple time stamp lines. When the receiver-smtp makes the "final delivery" of a message it inserts at the beginning of the mail data a return path line. The return path line preserves the information in the <reverse-path> from the MAIL command. Here, final delivery means the message leaves the SMTP world. The preceding two paragraphs imply that the final mail data will begin with a return path line, followed by one or more time stamp lines. These lines will be followed by the mail data header and body. A sample header from a mail I sent to myself is listed below. From malhotra_g@vsnl.net Fri Nov 7 19:17:53 2003 Return-Path: <malhotra_g@vsnl.net> Delivered-To: gaurav@deimos.csa.iisc.ernet.in Received: from csa.iisc.ernet.in (csa.iisc.ernet.in [144.16.67.8]) by deimos.csa.iisc.ernet.in (Postfix) with ESMTP id 8EF794E662 for <gaurav@deimos.csa.iisc.ernet.in> ; Fri, 7 Nov 2003 19:17:53 +0530 (IST)

Page 5 of 6 Received: by csa.iisc.ernet.in (Postfix) id 30AA52BDF9; Fri, 7 Nov 2003 18:57:32 +0530 (IST) Delivered-To: gaurav@csa.iisc.ernet.in Received: from smtp2.vsnl.net (smtp2.vsnl.net [203.200.235.232]) by csa.iisc.ernet.in (Postfix) with ESMTP id D45FA2BC9F for <gaurav@csa.iisc.ernet.in> ; Fri, 7 Nov 2003 18:57:31 +0530 (IST) Received: from vsnl.net ([127.0.0.1]) by smtp2.vsnl.net (iplanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) with ESMTP id <0HNZ00HE9I8UA7@smtp2.vsnl.net> for gaurav@csa.iisc.ernet.in; Fri, 07 Nov 2003 19:16:06 +0530 (IST) Received: from ([172.16.28.141]) by smtp2.vsnl.net (InterScan E-Mail VirusWall Unix); Fri, 07 Nov 2003 19:16:06 +0530 (IST) Received: from [172.16.28.182] by pop2.vsnl.net (mshttpd); Fri, 07 Nov 2003 18:46:06 +0500 I wrote this mail on the webmail interface provided by vsnl to its subscribers. Starting from the bottom, we can see the hosts that were traversed, before this mail was delivered to my mailbox on csa.iisc.ernet.in. Since this mail was written using webmail, the contents were received by the http server on vsnl. The http server forwarded this mail to a Virus Scanner which forwarded it to smtp2.vsnl.net. The mail was then sent to csa.iisc.ernet.in which is the mail exchanger for the csa.iisc.ernet.in domain. The mail has technically been delivered to me but since my mailbox physically resides on deimos.csa.iisc.ernet.in, csa.iisc.ernet.in internally forwards it to host deimos. Once the mail has reached deimos, I can open my mailreader and view the mail. Mail Exchangers Suppose you have an email ID, how do you find out the address of the smtp server to which mail for that ID is supposed to be sent? The answer to this is provided by DNS. MX records in the DNS database store the Mail exchangers for a domain. A mail exchanger is the host name of a smtp server that is a gateway for all mails entering a domain. In other words, it is a server that takes care of all mails sent to addresses within that domain. When an smtp server needs to send an email to a address, say abc@xyz.com it queries the DNS for the mail exchangers for xyz.com. The sender can then connect to the mail exchanger and deliver the message. It is possible for a single domain to have multiple mail exchangers for reliability. Querying the DNS for Mail Exchangers for hotmail.com yielded the following results: mx2.hotmail.com mx3.hotmail.com mx4.hotmail.com mx1.hotmail.com Note that mail exchangers will typically only accept mails addressed to users within that domain. SMTP servers provided by your ISP or local system administrator will accept mails for any destination and then relay it to the appropriate mail exchanger.

Page 6 of 6 An example SMTP Transaction using Telnet If you are in CSA at IISc, you may want to learn how to use telnet from within the Computing Lab. In this section I will show you a sample interaction I had while sending mail (to myself :)) using telnet. Note that SMTP servers listen to port number 25. The lines entered by me are prefixed by a "C:" and the server's replies are prefixed with a "S:". This is the approximate sequence of commands that would be used by a server sending mail to another. C: ]$ telnet mx1.vsnl.net 25 Trying 203.200.235.229... Connected to mx1.vsnl.net. Escape character is '^]'. S: 220 mx1.vsnl.net -- Server ESMTP (iplanet Messaging Server 5.2 HotFix 1.16 (built May 14 2003)) C: HELO csa.iisc.ernet.in S: 250 mx1.vsnl.net OK, [144.16.67.10]. C: VRFY malhotra_g S: 252 2.5.0 Possible local address <malhotra_g@mx1.vsnl.net> C: MAIL FROM:<gaurav@csa.iisc.ernet.in> S: 250 2.5.0 Address Ok. C: RCPT TO:<malhotra_g@vsnl.net> S: 250 2.1.5 malhotra_g@vsnl.net OK. C: DATA S: 354 Enter mail, end with a single ".". C: Subject: test C: This is a test. C:. S: 250 2.5.0 Ok. C: QUIT S: 221 2.3.0 Bye received. Goodbye. Connection closed by foreign host. Further References Want to learn more? RFC 821 - Simple Mail Transfer Protocol RFC 2045 - Multipurpose Internet Mail Extensions (MIME) RFC 822 - Standard for the format of ARPA Internet text messages Back to Network Programming