Mail Protocols SMTP POP IMAP Presenter Pham Tung

  • Slides: 31
Download presentation
Mail Protocols: SMTP, POP, IMAP Presenter: Pham Tung Linh Networked Systems Laboratory Department of

Mail Protocols: SMTP, POP, IMAP Presenter: Pham Tung Linh Networked Systems Laboratory Department of IT Convergence Engineering Kumoh National Institute of Technology, South Korea 10/26/2021 1 http: //nsl. kumoh. ac. kr/

Overview Introduction & Objective Push mail Principle based SMTP Pull mail Principle based POP,

Overview Introduction & Objective Push mail Principle based SMTP Pull mail Principle based POP, IMAP Practice: Create a SMTP client by C++ with winsock library Send an email to a specific email address. Exercises 10/26/2021 http: //nsl. kumoh. ac. kr/ 2

Introduction 10/26/2021 http: //nsl. kumoh. ac. kr/ 3

Introduction 10/26/2021 http: //nsl. kumoh. ac. kr/ 3

Mail Protocols Two ways: Push mail: SMTP Pull mail: POP 3, IMAP Web-based email

Mail Protocols Two ways: Push mail: SMTP Pull mail: POP 3, IMAP Web-based email 10/26/2021 http: //nsl. kumoh. ac. kr/ 4

Mail Protocols POP 3/IMAP 10/26/2021 http: //nsl. kumoh. ac. kr/ 5

Mail Protocols POP 3/IMAP 10/26/2021 http: //nsl. kumoh. ac. kr/ 5

SMTP: Simple Mail Transfer Protocol The standard e-mail protocol on the Internet and part

SMTP: Simple Mail Transfer Protocol The standard e-mail protocol on the Internet and part of the TCP/IP protocol suite. SMTP defines the message format and the message transfer agent (MTA), which stores and forwards the mail. SMTP was originally designed for only plain text (ASCII text), but MIME and other encoding methods enable executable programs and multimedia files to be attached to and transported with the e-mail message SMTP is a relatively simple, text-based protocol, where one or more recipients of a message are specified and then the message text is transferred. SMTP uses TCP port 25. 10/26/2021 http: //nsl. kumoh. ac. kr/ 6

SMTP: Simple Mail Transfer Protocol The primary purpose of SMTP is to transfer email

SMTP: Simple Mail Transfer Protocol The primary purpose of SMTP is to transfer email between mail servers. However, it is critical for email clients as well. In order to send email, the client sends the message to an outgoing mail server, which in turn contacts the destination mail server for delivery. For this reason, it is necessary to specify an SMTP server when configuring an email client. One important point to make about the SMTP protocol is that it does not require authentication. This allows anyone on the Internet to send email to anyone else or even to large groups of people. It is this characteristic of SMTP that makes junk email or spam possible. 10/26/2021 http: //nsl. kumoh. ac. kr/ 7

SMTP… Transfers mails from one host to another Collects mail and delivers to user

SMTP… Transfers mails from one host to another Collects mail and delivers to user agent Composes, reads, replies to , forwards and handles mailboxes 10/26/2021 http: //nsl. kumoh. ac. kr/ 8

SMTP Message transfer… SMTP is a push protocol 10/26/2021 http: //nsl. kumoh. ac. kr/

SMTP Message transfer… SMTP is a push protocol 10/26/2021 http: //nsl. kumoh. ac. kr/ 9

Email Structure 10/26/2021 http: //nsl. kumoh. ac. kr/ 10

Email Structure 10/26/2021 http: //nsl. kumoh. ac. kr/ 10

How it work? Command format: Keyword: argument(s) Response format: 3 -digit status code Link

How it work? Command format: Keyword: argument(s) Response format: 3 -digit status code Link Layer PCI IP-PCI 10/26/2021 TCP-PCI http: //nsl. kumoh. ac. kr/ SMTP command/response 11

Usual Commands 10/26/2021 http: //nsl. kumoh. ac. kr/ 12

Usual Commands 10/26/2021 http: //nsl. kumoh. ac. kr/ 12

Usual Code Responses 10/26/2021 http: //nsl. kumoh. ac. kr/ 13

Usual Code Responses 10/26/2021 http: //nsl. kumoh. ac. kr/ 13

How it works? Connection Establishment 10/26/2021 http: //nsl. kumoh. ac. kr/ 14

How it works? Connection Establishment 10/26/2021 http: //nsl. kumoh. ac. kr/ 14

How it works? Message Transfer 10/26/2021 http: //nsl. kumoh. ac. kr/ 15

How it works? Message Transfer 10/26/2021 http: //nsl. kumoh. ac. kr/ 15

How it works? Connection Termination 10/26/2021 http: //nsl. kumoh. ac. kr/ 16

How it works? Connection Termination 10/26/2021 http: //nsl. kumoh. ac. kr/ 16

Pull mail Protocol 10/26/2021 http: //nsl. kumoh. ac. kr/ 17

Pull mail Protocol 10/26/2021 http: //nsl. kumoh. ac. kr/ 17

Pull mail Protocol POP 3: Post Office Protocol Ver. 3 IMAP 4: Internet Mail

Pull mail Protocol POP 3: Post Office Protocol Ver. 3 IMAP 4: Internet Mail Access Protocol Ver. 4 10/26/2021 http: //nsl. kumoh. ac. kr/ 18

POP 3 An Application-layer Internet standard protocol used by local e-mail clients to retrieve

POP 3 An Application-layer Internet standard protocol used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection. the most popular offline approach Simple Allows the user to obtain a list of their Emails Users can retrieve their emails Users can either delete or keep the email on their system Minimizes server resources 10/26/2021 http: //nsl. kumoh. ac. kr/ 19

POP 3 10/26/2021 http: //nsl. kumoh. ac. kr/ 20

POP 3 10/26/2021 http: //nsl. kumoh. ac. kr/ 20

POP 3 Simple protocol Easier to implement Copies all messages when connection is made.

POP 3 Simple protocol Easier to implement Copies all messages when connection is made. When not connected, still access and read downloaded mail Dose not allow to set and manage folders When you down load mails the server does not keep them If mail in different format, hassle to transfer mail 10/26/2021 http: //nsl. kumoh. ac. kr/ 21

IMAP An Application Layer Internet protocol that allows an email client to access email

IMAP An Application Layer Internet protocol that allows an email client to access email on a remote mail server Originally from Stanford University 1968 Developed after POP and attempts to fix POP deficiencies Allows keeping all mail on the server Allows mail categorization via folder metaphor Mail is easily flagged (answered, draft, deleted, seen, recent); this isn’t the same on all servers Provides for multiple connections to the server 10/26/2021 http: //nsl. kumoh. ac. kr/ 22

IMAP Can access/manage multiple mail boxes can store message New/old mail can be accessed

IMAP Can access/manage multiple mail boxes can store message New/old mail can be accessed from any PC. Client independent Switch mail to client PC without affecting user mail Fewer client than POP 3 Slower than POP 3 More complex 10/26/2021 http: //nsl. kumoh. ac. kr/ 23

POP Vs. IMAP POP 3 access from any Used by one client/computer/any where. Store

POP Vs. IMAP POP 3 access from any Used by one client/computer/any where. Store mail on server Folder can be server and clients. Send message back and forth Store mail on client 10/26/2021 computer organizing mail into clientside folder. Send messages one way. http: //nsl. kumoh. ac. kr/ 24

Web-Based Mail Any email client implemented as a web application accessed via a web

Web-Based Mail Any email client implemented as a web application accessed via a web browser. Ex: Gmail, Yahoo! Mail, Hotmail, Naver… Ability to send/receive email anywhere from a web browser Main disadvantage is the need to be connected to the internet while using 10/26/2021 http: //nsl. kumoh. ac. kr/ 25

Practice Objective: Create a SMTP client by C++ Allow to send an email to

Practice Objective: Create a SMTP client by C++ Allow to send an email to a specific email address 10/26/2021 http: //nsl. kumoh. ac. kr/ 26

Practice Step by Step: Initialize Winsock 2 (Function: WSAStartup) Get socket descriptor on the

Practice Step by Step: Initialize Winsock 2 (Function: WSAStartup) Get socket descriptor on the local machine (Function: socket). Convert port value (i. e. , 25) to TCP/IP byte order (Function: htons). Obtain Internet address of the remote machine (Functions: inet_addr, gethostbyname). Set socket parameters (Function: ioctl/ioctlsocket). Connect to the remote server (Function: connect). Introduce yourself - EHLO <SP> <domain> <CRLF>. Send AUTH LOGIN <CRLF> and another command described in the section "Typical scenarios while sending the email" (Functions: send, recv). Finish the conversation with QUIT <CRLF>. Close connection with remote machine (Function: close/closesocket). In Windows only, free Winsock 2 resources (Function: WSACleanup). 10/26/2021 http: //nsl. kumoh. ac. kr/ 27

Practice Main Program: 10/26/2021 http: //nsl. kumoh. ac. kr/ 28

Practice Main Program: 10/26/2021 http: //nsl. kumoh. ac. kr/ 28

Practice Try to send an email to me!!!! Email content: Subject: Network Programming Class

Practice Try to send an email to me!!!! Email content: Subject: Network Programming Class Body: Your full name (You can attach your photos if you want) My email: tunglinh. ptit@gmail. com 10/26/2021 http: //nsl. kumoh. ac. kr/ 29

Exercise Show the mentioned email protocols (For Push and Pull mail) and express the

Exercise Show the mentioned email protocols (For Push and Pull mail) and express the Pros/Cons of each protocol. Summarize our class today (Main content) 10/26/2021 http: //nsl. kumoh. ac. kr/ 30

Thank you very much for your attention Questions/Answers Time Networked Systems Laboratory Department of

Thank you very much for your attention Questions/Answers Time Networked Systems Laboratory Department of IT Convergence Engineering Kumoh National Institute of Technology, South Korea 10/26/2021 31 http: //nsl. kumoh. ac. kr/