smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 ·...
Transcript of smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 ·...
![Page 1: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/1.jpg)
Concept of Mail Protocols
bdNOG7,Dhaka.
![Page 2: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/2.jpg)
Format of an Email
![Page 3: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/3.jpg)
Email AddressingA unique addressing system ,has two parts in addressing.
Local part defines user mailbox and domain name mention the destination
Email alias:Create a group email to send email to many people like multicast.
![Page 4: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/4.jpg)
Email message fieldsHere are the meanings of the fields to be filled in when you send an email:
From: this is your email address;; most of the time you will not have to fill in this field, because it is generally set by the email client according to your preferences.
To: This field is used for the recipient's email address. Subject: this is the title that your recipients will see when they want to read the email Cc (carbon copy): this allows an email to be send to a large number of people by writing their respective addresses separated by
commas Bcc (blind carbon copy): This is a Cc, except that the recipient does not see the list of people in the Bcc field Message: This is the body of yourmessage
Other email functions are:
Attached Files, Attachments: A file can be attached to an email by specifying its location on the hard drive. Signature: If the email client allows it, you are often able to set a signature, meaning a few lines of text which will be added to the
end of the document.
![Page 5: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/5.jpg)
Email DeliveryQueue
Unlike ftp/http it is not necessarily to deliver email in real time.Delivery not instantaneous ,It will wait in the queue of outgoing,incoming ,intermediate MTA message queue.
![Page 6: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/6.jpg)
Component of Email system Mail Transport Agent/Message Transfer Agent (MTA) Mail User Agent (MUA)
Mail Delivery Agent(MDA)
![Page 7: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/7.jpg)
MTAThe actual mail transfer is done through message transfer agents (MTAs). To send mail, a system must have the client MTA, and to receive mail, a system must have a server MTA. The formal protocol that defines the MTA client and server in the Internet is called Simple Mail Transfer Protocol (SMTP).
SMTP uses commands and responses to transfer mail between an MTA client and MTA server.
![Page 8: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/8.jpg)
SMTP Mail transfer Flow
![Page 9: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/9.jpg)
MTA connection setup
![Page 10: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/10.jpg)
MTA Connection Setup..Contd..Sender opens TCP connection with receiver Once connected, receiver identifies itself 220 service ready Sender identifies itself HELO <domain> Receiver accepts sender’s identification 250OK If mail service not available, step 2 above becomes: 421 service not available
![Page 11: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/11.jpg)
SMTP Exchange of command response pair
![Page 12: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/12.jpg)
Message TransferSender may send one or more messages to receiver Each message transfer has the following phases: One MAIL command, identifies originator•Gives reverse path to use for error reporting•Receiver returns 250 OK or appropriate fail/error messageOne or more RCPT commands, identifies recipients for the message• Each recipient identified by a separate RCPT• Separate reply for each recipient (250 OK etc.) One DATA command transfers message text• End of message indicated by line containing just period (.)
![Page 13: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/13.jpg)
MTA connection termination
![Page 14: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/14.jpg)
MTA connection terminationSender sends QUIT and waits for reply
Then initiate TCP close operation
Receiver initiates TCP close after sending reply to QUIT
![Page 15: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/15.jpg)
OptimizationIf message is sent to multiple users on a given host,it is sent only once.
Delivery to users handled by destination host
If Multiple messages are ready for given host,a single TCP connection can be used.
Saves overhead of setting up and termination of connection
![Page 16: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/16.jpg)
Possible Errors Host unreachable Host out of operation TCP connection fail during transfer Faulty destination address
User errorTarget user address has changed Redirect if possibleInform user if not
Sender re-queue the mail - will retry till a configurable period of time
![Page 17: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/17.jpg)
SMTP protocol reliability TCP connection is used to transfer mail from sender to receiver over TCP
connection Attempts to provide reliable service No guarantee to recover lost messages No end-to-end ack to sender Error indication report not guaranteed
![Page 18: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/18.jpg)
SMTP receiver Accepts arriving message Places in user mailbox or copies to outbound message queue for forwarding Receivermust
verify local mail destination deal with errors Transmission Lack of disk space
![Page 19: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/19.jpg)
SMTP status codes(DSN-Delivery status Notification)
Leading digits Indicates catagories
2XX-Positive Completion Reply(Successful)
3XX-Positive Intermediate Reply(Redirection)
4XX-Transient negative completion reply(Client error)
5XX-Permanent negative completion reply(Server error)
![Page 20: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/20.jpg)
SMTP status codes..Cont.
![Page 21: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/21.jpg)
POP3Mail access protocol:
POST OFFICE PROTOCOL [RFC 1939]
Simple and limited functionality,Consists of client software and Server software, Server performs user authorization
IMAP: Internet mail access protocol [Version 4]
![Page 22: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/22.jpg)
POP3Retrieves messages from a mail server
Typically, messages are downloaded to your mail client, and deleted from the server
Designed for use with dial-up connections when people were intermittently connected
Listens on Port 110 (with Secure POP generally on port 995)
![Page 23: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/23.jpg)
POP3 ConnectionEstablishment
![Page 24: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/24.jpg)
POP3 protocol sessionroot@amberit ~]# telnet mail.amberit.com.bd 110 Trying 206.71.88.102...Connected to mail.amberit.com.bd. Escape character is '^]'.+OK Dovecot ready. user [email protected]+OKpass letmein+OK Logged in. list+OK 1messages:1 482.retr1+OK 482 octets<snip>MessageHeaders</snip>This is my short message quit+OK Logging out.
![Page 25: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/25.jpg)
Basic POP3 commandsUSER <name> - identifies the user
PASS <password> - authentication for user STAT - lists all messages in the mailbox of user LIST <msg no.> - lists the content of a message RETR <msg no.> - retrieves a particular message DELE <msg no.> - Deletes a particular message NOOP RSET QUIT
Replies +OK–ERR
![Page 26: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/26.jpg)
IMAP Protocol session[root@amberit ~]# telnet mail.amberit.com.bd 143 Trying 206.71.88.102...
Connected to mail.amberit.com.bd Escape character is '^]'.* OK Dovecot ready.A1 LOGIN [email protected] letmein A1 OK Logged in.A2 SELECT Inbox* FLAGS (\Answered \Flagged \Deleted \Seen \Draft)*
![Page 27: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/27.jpg)
IMAP Protocol session..cont.OK [PERMANENTFLAGS (\Answered \Flagged \Deleted \Seen \Draft \*)] Flags permitted.* 1 EXISTS* 0 RECENT* OK [UIDVALIDITY 1225333589] UIDs valid* OK [UIDNEXT 2] Predicted next UIDA2 OK [READ-WRITE] Select completed. A3 FETCH 1 BODY[HEADER]* 1 FETCH (BODY[HEADER] 454<snip> Message Header Delivered</snip> A3 OK Fetch completed.A4 LOGOUT* BYE LoggingoutA4 OK Logout completed. Connection closed by foreign host.
![Page 28: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/28.jpg)
Webmail
![Page 29: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/29.jpg)
MIME(Multipurpose Internet Mail Extensions)
![Page 30: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/30.jpg)
MIMEMainmotivationSMTP can not transmit executables, images, audio/video clips, International characters (e.g. â, å, ä, è, é, ê, ë) that require 8-bit ASCII etc.
MIME (Multipurpose Internet Mail Extensions) Allows other types of non-text data to be carried by SMTP Encodes image, video clip, voice data as text data to betransmitted over SMTP RFC2045-2049Defines new header fields, standardized content formats, and encodings to transfer them over mail
![Page 31: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/31.jpg)
Email header with MIME [RFC 2045]
![Page 32: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/32.jpg)
MIME Email headerDefines five new message header fields:MIME-Version: version no. Content-Type: type of data in bodyContent-transfer-encoding: type of encoding used Content-ID: uniquely identify MIME entityContent Description: plain text description of body
![Page 33: smtp tutorial bdnog7wiki.bdnog.org/lib/exe/fetch.php/bdnog7/smtp_tutorial... · 2017-11-21 · EmailAddressing A"unique"addressing"system",hastwo"partsin addressing. Local&part&definesuser&mailboxand&domain&name&mention&the&destination&&](https://reader033.fdocuments.in/reader033/viewer/2022042414/5f2f3e120c1ae37dd55f006a/html5/thumbnails/33.jpg)
MIME 1.1