SMTP - Simple Mail Transfer Protocol ====================================== .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is SMTP?** SMTP stands for Simple Mail Transfer Protocol. It is a standard communication protocol used to send emails from one server to another over the internet. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is SMTP useful?** * It enables email delivery between different email servers (e.g., from Gmail to Outlook). * Supports authentication and encryption to secure email transmission. * Works with other protocols like IMAP and POP3 to complete the email lifecycle (sending + receiving). * Widely supported by all major email clients and services. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** * User sends an email using an email client (like Outlook or Gmail). * The email client connects to the SMTP server and sends the message. * The SMTP server processes the message and determines the recipient’s domain. * It forwards the email to the recipient’s mail server (using DNS to find it). * The recipient’s server stores the email, ready to be fetched by the user via IMAP or POP3. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is SMTP used?** * Email clients (e.g., Outlook, Thunderbird, Apple Mail). * Mail servers (e.g., Microsoft Exchange, Postfix, Sendmail). * Webmail services (e.g., Gmail, Yahoo Mail, Zoho). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why OSI Layer: Application Layer (Layer 7)?** * It defines email commands (HELO, MAIL FROM, RCPT TO, DATA, etc.). * It interacts with user-facing applications (e.g., Outlook, Gmail). * It handles message formatting and transfer logic, not data transport or routing. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the key features?** * Outbound Email Protocol. * Text-Based Protocol. * Supports Authentication (SMTP AUTH). * Port Flexibility. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is an SMTP server?** A server that: * Accepts outgoing email. * Relays email to destination servers. * Examples: Sendmail, Postfix, Exim, Microsoft Exchange, Gmail SMTP. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is a mail relay in SMTP?** A mail relay is when an SMTP server forwards email from one domain/server to another. Used in: * Email routing between domains. * Sending mail from client to provider’s SMTP. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Can SMTP be used over IPv6?** Yes. SMTP works over both IPv4 and IPv6 as long as the DNS records and mail servers support it. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are some applications that use SMTP?** * Email Clients. * Webmail Services. * Web Applications & Contact Forms. * Command-Line Tools & Scripts. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the working flow of SMTP?** User Composes Email * You write an email in a mail client (e.g., Outlook, Gmail, Thunderbird). * Click “Send”. Mail Client Connects to SMTP Server * The client connects to the SMTP server on port: * 587 (with STARTTLS encryption – most common). * 465 (SSL/TLS). * 25 (for server-to-server). Client Authenticates * The mail client logs in using: * Username and password. * Uses AUTH LOGIN or AUTH PLAIN commands. Email Envelope is Sent * The client sends: * MAIL FROM: – sender's email address. * RCPT TO: – recipient’s email address. Message Content is Sent * The client sends: * DATA command. * Followed by the email body, subject, headers, and attachments (in MIME format). * Ends with a single dot . on a new line to finish the message. Email is Queued or Relayed * The SMTP server either: * Delivers the email locally, or * Looks up recipient’s domain via DNS (MX record) and relays the message to the recipient’s mail server. Recipient Server Accepts the Mail * The recipient mail server stores the email in the user's inbox. * The recipient will later fetch it using POP3 or IMAP. Client Sends QUIT * The SMTP session ends with the QUIT command. * The server closes the connection. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are common SMTP server software options?** * Postfix - Linux. * Sendmail - Linux/Unix. * Exim - Linux. * MailEnable - Windows. * hMailServer - Windows. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow Topics in this section, * :ref:`Learnings in this section ` * :ref:`Terminology ` * :ref:`Version Info ` * :ref:`SMTP Version&RFC Details ` * :ref:`SMTP Basic Setup on Ubuntu using IPv4 ` * :ref:`SMTP Basic Setup on Ubuntu using IPv6 ` * :ref:`SMTP Protocol Packet Details ` * :ref:`SMTP Usecases ` * :ref:`SMTP Basic Features ` * :ref:`SMTP Feature : Text Based Protocol ` * :ref:`SMTP Feature : Client Server Architecture ` * :ref:`SMTP Feature : Store and Forward Mechanism ` * :ref:`SMTP Feature : Port Based Communication ` * :ref:`SMTP Feature : Command Set Feature ` * :ref:`SMTP Feature : Encryption Support ` * :ref:`SMTP Feature : Interoperability ` * :ref:`SMTP Feature : Support For Authentication ` * :ref:`SMTP Feature : Header And Body Seperation ` * :ref:`SMTP Feature : Reliable Delivery ` * :ref:`Reference links ` .. _SMTP_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _SMTP_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _SMTP_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _SMTP_step5: .. tab-set:: .. tab-item:: SMTP Version&RFC Details .. csv-table:: :file: ./SMTP/SMTP_RFC.csv :widths: 1,10,10,10,30 :header-rows: 1 .. _SMTP_step20: .. tab-set:: .. tab-item:: SMTP Basic Setup on Ubuntu using IPv4 * setup .. _SMTP_step21: .. tab-set:: .. tab-item:: SMTP Basic Setup on Ubuntu using IPv6 * setup .. _SMTP_step6: .. tab-set:: .. tab-item:: SMTP Protocol Packet Details **SMTP COMMAND LINE Packet** .. csv-table:: :file: ./SMTP/SMTP_Command_Line_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **SMTP RESPONSE LINE Packet** .. csv-table:: :file: ./SMTP/SMTP_Response_Line_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **SMTP MESSAGE HEADER Packet** .. csv-table:: :file: ./SMTP/SMTP_Message_Header_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **SMTP MESSAGE BODY Packet** .. csv-table:: :file: ./SMTP/SMTP_Message_Body_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **SMTP END Of Data Marker Packet** .. csv-table:: :file: ./SMTP/SMTP_End_of_Data_Marker_Packet.csv :widths: 10,20,30,10 :header-rows: 1 .. _SMTP_step7: .. tab-set:: .. tab-item:: SMTP Usecases .. csv-table:: :file: ./SMTP/SMTP_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _SMTP_step8: .. tab-set:: .. tab-item:: SMTP Basic Features .. csv-table:: :file: ./SMTP/SMTP_Features.csv :widths: 10,10,30 :header-rows: 1 .. _SMTP_step9: .. tab-set:: .. tab-item:: SMTP Feature : Text Based Protocol **Text Based Protocol - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature1_Text_Based_Protocol_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step10: .. tab-set:: .. tab-item:: SMTP Feature : client Server Architecture **Client Server Architecture - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature2_Client_Server_Architecture_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step11: .. tab-set:: .. tab-item:: SMTP Feature : Store And Forward Mechanism **Store And forward Mechanism - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature3_Store_and_Forward_Mechanism_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step12: .. tab-set:: .. tab-item:: SMTP Feature : Port Based Communication **Port Based Communication - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature4_Port_Based_Communication_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step13: .. tab-set:: .. tab-item:: SMTP Feature : Command Set Feature **Command Set Feature - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature5_Command_Set_Feature_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step14: .. tab-set:: .. tab-item:: SMTP Feature : Encryption Support **Encryption Support - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature6_Encryption_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step15: .. tab-set:: .. tab-item:: SMTP Feature : interoperability **interoperability - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature7_Interoperability_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step16: .. tab-set:: .. tab-item:: SMTP Feature : Support For Authentication **Support For Authentication - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature8_Support_for_Authentication_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step17: .. tab-set:: .. tab-item:: SMTP Feature : Header And Body Seperation **Header And Body Seperation - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature9_Header_and_Body_Separation_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step18: .. tab-set:: .. tab-item:: SMTP Feature : Reliable Delivery **Reliable Delivery - Testcases** .. csv-table:: :file: ./SMTP/SMTP_Feature10_Reliable_Delivery_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _SMTP_step19: .. tab-set:: .. tab-item:: Reference links * Reference links