POP3 - Post Office Protocol version 3 ======================================== .. 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 POP3?** POP3 stands for Post Office Protocol version 3. It is a standard email protocol used to retrieve emails from a mail server to a local computer. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Why is POP3 useful?** POP3 downloads emails to our device, so we can read them even without an internet connection. It also helps free up space on the email server by deleting emails from the server after downloading (optional). POP3 is easy to configure and works with most email clients like Outlook, Thunderbird, etc. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How it works?** * Email arrives at our mail server. * Our email client connects to the server using POP3. * It authenticates using our username and password. * The client downloads the emails from the server to our local device. * Depending on settings, it may delete the emails from the server. * We can now read emails offline on our device. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Where is POP3 used?** * In personal email clients like Microsoft Outlook, Mozilla Thunderbird, etc. * When users prefer to store emails locally instead of keeping them online. * In low-bandwidth environments where constant internet access isn’t available. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which OSI layer does POP3 belong to?** * It provides name resolution services to applications and users. * POP3 is used by email client software to retrieve emails from the server. * It deals with data formatting, user authentication, and communication with the mail server, which are functions of the Application Layer (Layer 7). .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are the key features?** * Download-and-Delete Model * One Inbox Only * Single-Device Oriented * Pull-Based Communication .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Can POP3 be used with multiple devices?** Not efficiently. POP3 is designed for single-device use. Using it with multiple devices may cause: * Email duplication * Inconsistent inboxes * Missing messages .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What happens if the internet disconnects during retrieval?** * Partial downloads may be lost. * Email might be redownloaded on the next connection. * If `DELE` hasn’t been processed, the email stays on the server. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **How is retransmission handled in POP3?** If an ACK is not received within the timeout interval, POP3 retransmits the segment. Modern POP3 uses: * Timeout-based retransmission * Fast retransmit (based on duplicate ACKs) .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What are some applications that use POP3?** * Email Clients (Desktop-Based) * Mobile Email Apps (with manual setup) * Automated Systems / Scripts * Web-Based Services .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **What is the working flow of POP3?** * **Email Client Connects to the Mail Server** * The user opens an email app. * The client connects to the mail server on: * Port 110 (plain POP3) * Port 995 (POP3 over SSL/TLS) * **Client Authenticates** * The client sends: * `USER` - username * `PASS` - password * If correct, the server allows access. * **Client Checks for Messages** * The client asks how many messages are available: * `STAT` - gives number and total size * `LIST` - lists each email with its size * **Client Downloads Emails** * The client uses `RETR ` to download each email. * Emails are saved locally on the device (inbox folder or storage). * **Client Ends the Session** * The client sends: * `QUIT` - ends session and deletes emails marked by `DELE` * Connection is closed. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **When is POP3 preferred over IMAP?** * Low-storage servers * Offline access needed * Single-device users * Simple use cases (e.g., automated systems downloading logs) .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is POP3 Windows specific?** * No, POP3 (Post Office Protocol version 3) is **not Windows-specific**. * It is supported across multiple platforms including Windows, macOS, Linux, and mobile OSes. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is POP3 Linux specific?** * No, POP3 is **not Linux-specific**. * It works on various operating systems and is supported by most email clients and servers. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Transport Protocol is used by POP3?** * POP3 uses the **Transmission Control Protocol (TCP)** to ensure reliable communication between the client and server. .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Which Port is used by POP3?** * POP3 commonly uses: * **Port 110** for unencrypted or STARTTLS connections * **Port 995** for POP3 over SSL/TLS (encrypted communication) .. panels:: :container: container pb-4 :column: col-lg-12 p-2 :card: shadow **Is POP3 using client-server model?** * Yes, POP3 uses a **client-server model**. * The **email client** connects to the **mail server** to download emails, which are usually deleted from the server after retrieval. .. 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:`POP3 Version&RFC Details ` * :ref:`POP3 Basic Setup on Ubuntu using IPv4 ` * :ref:`POP3 Basic Setup on Ubuntu using IPv6 ` * :ref:`POP3 Protocol Packet Details ` * :ref:`POP3 Usecases ` * :ref:`POP3 Basic Features ` * :ref:`POP3 Feature : Simple Protocol ` * :ref:`POP3 Feature : Email Download ` * :ref:`POP3 Feature : Offline Access ` * :ref:`POP3 Feature : Server Cleanup ` * :ref:`POP3 Feature : Limited Command ` * :ref:`POP3 Feature : Authentication Support ` * :ref:`POP3 Feature : Port Based Authentication ` * :ref:`POP3 Feature : No Folder Support ` * :ref:`POP3 Feature : Optional TLS Encryption ` * :ref:`Reference links ` .. _POP3_step1: .. tab-set:: .. tab-item:: Learnings in this section * In this section, you are going to learn .. _POP3_step2: .. tab-set:: .. tab-item:: Terminology * Terminology .. _POP3_step3: .. tab-set:: .. tab-item:: Version Info * Version Info .. _POP3_step5: .. tab-set:: .. tab-item:: POP3 Version&RFC Details .. csv-table:: :file: ./POP3/POP3_RFC.csv :widths: 1,10,10,10,30 :header-rows: 1 .. _POP3_step19: .. tab-set:: .. tab-item:: POP3 Basic Setup on Ubuntu using IPv4 **POP3 Email Server Setup Test Case (IPv4)** * This test verifies the setup of a POP3 email server on Ubuntu using Postfix and Dovecot. The client connects to the server using Telnet to retrieve mail over POP3 (port 110). * Server IP: 192.168.56.10 * Client IP: 192.168.56.11 * Protocol: POP3 over IPv4 * Step-1: Setup Email Server (192.168.56.10) Update and upgrade packages: .. code-block:: shell test1:~$ sudo apt update && sudo apt upgrade -y Install Postfix and Dovecot: .. code-block:: shell test1:~$ sudo apt install postfix dovecot-pop3d -y During Postfix configuration: - Select **Internet Site** - Set hostname (e.g., `mail.localdomain`) Add a test mail user: .. code-block:: shell test1:~$ sudo adduser testuser # Set password when prompted Enable Maildir for mailbox storage: .. code-block:: shell test1:~$ sudo postconf -e "home_mailbox = Maildir/" test1:~$ sudo mkdir /home/testuser/Maildir test1:~$ sudo chown -R testuser:testuser /home/testuser/Maildir Configure Dovecot for POP3: 1. Edit the Dovecot main configuration: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/dovecot.conf protocols = pop3 2. Set Maildir path: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-mail.conf mail_location = maildir:~/Maildir Restart services to apply changes: .. code-block:: shell test1:~$ sudo systemctl restart postfix test1:~$ sudo systemctl restart dovecot * Step-2: Allow POP3 Port in Firewall If using `ufw`, allow the necessary ports: .. code-block:: shell test1:~$ sudo ufw allow 110/tcp # POP3 test1:~$ sudo ufw allow 25/tcp # SMTP (Postfix - optional) test1:~$ sudo ufw enable * Step-3: Setup and Test from Client (192.168.56.11) Install Telnet (if not installed): .. code-block:: shell test2:~$ sudo apt install telnet -y Connect to POP3 server: .. code-block:: shell test2:~$ telnet 192.168.56.10 110 +OK Dovecot ready. Issue POP3 commands: USER testuser PASS your_password +OK Logged in. LIST RETR 1 QUIT * Expected Results: - Telnet connects successfully to port 110 - Dovecot responds with POP3 welcome message - User can authenticate using POP3 credentials - LIST and RETR commands return available emails * Step-4: Wireshark Capture :download:`Download Wireshark capture ` * Troubleshooting Tips: - Monitor mail logs in real time: .. code-block:: shell test1:~$ tail -f /var/log/mail.log - Verify Maildir exists and is owned by the correct user: .. code-block:: shell test1:~$ ls -ld /home/testuser/Maildir - Check Dovecot authentication and configuration: .. code-block:: shell test1:~$ sudo dovecot -n test1:~$ sudo systemctl status dovecot **SMTP + POP3 Mail Server Setup Test Case (IPv4)** * Client sends mail to server over SMTP and retrieves it via POP3. * Mail stored in Maildir format on the server. * Server IP: 192.168.56.10 * Client IP: 192.168.56.11 * Step-1: Server Setup 1. Install Required Packages: .. code-block:: shell test1:~$ sudo apt update test1:~$ sudo apt install postfix dovecot-pop3d -y During Postfix installation: - Choose: **Internet Site** - Mail name: `mail.localdomain` 2. Configure Postfix: .. code-block:: shell test1:~$ sudo nano /etc/postfix/main.cf myhostname = mail.localdomain myorigin = /etc/mailname mydestination = localhost, localhost.localdomain, mail.localdomain mynetworks = 192.168.56.0/24, 127.0.0.0/8 inet_interfaces = all inet_protocols = ipv4 home_mailbox = Maildir/ Create mailname file: .. code-block:: shell test1:~$ echo "mail.localdomain" | sudo tee /etc/mailname Restart postfix: .. code-block:: shell test1:~$ sudo systemctl restart postfix 3. Create Mail User: .. code-block:: shell test1:~$ sudo adduser testuser Create Maildir for testuser: .. code-block:: shell test1:~$ sudo -u testuser maildirmake.dovecot /home/testuser/Maildir test1:~$ sudo chown -R testuser:testuser /home/testuser/Maildir 4. Configure Dovecot for POP3: a. Set mail location: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-mail.conf mail_location = maildir:~/Maildir b. Enable plaintext authentication (testing only): .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-auth.conf disable_plaintext_auth = no c. Enable POP3 protocol: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/dovecot.conf protocols = pop3 d. Enable POP3 listener on port 110: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-master.conf service pop3-login { inet_listener pop3 { port = 110 } } Restart Dovecot: .. code-block:: shell test1:~$ sudo systemctl restart dovecot 5. Open required firewall ports: .. code-block:: shell test1:~$ sudo ufw allow 25/tcp # SMTP test1:~$ sudo ufw allow 110/tcp # POP3 test1:~$ sudo ufw reload * Step-2: Test from Client 1. Send Mail via SMTP (client): From client machine (192.168.56.11): .. code-block:: shell test2:~$ telnet 192.168.56.10 25 HELO client.localdomain MAIL FROM: RCPT TO: DATA Subject: POP3 Test Mail This is a test mail sent via SMTP for POP3 retrieval. . QUIT 2. Verify Mail Delivery on Server: .. code-block:: shell test1:~$ sudo ls /home/testuser/Maildir/new/ Check new mail file exists. 3. Retrieve Mail via POP3 (client): From client machine (192.168.56.11): .. code-block:: shell test2:~$ telnet 192.168.56.10 110 +OK Dovecot ready. user testuser +OK pass +OK Logged in. list +OK 1 messages: 1 456 . retr 1 +OK [Message content appears here] . quit * Step-4: Wireshark Capture :download:`Download Wireshark capture ` .. _POP3_step20: .. tab-set:: .. tab-item:: POP3 Basic Setup on Ubuntu using IPv6 **POP3 Email Server Setup Test Case (IPv6)** * This test verifies the configuration of a POP3 email server using Postfix and Dovecot over IPv6. It ensures a client can connect using IPv6 and retrieve emails using standard POP3 commands. * Server IPv6 Address: fd00:56::10 * Client IPv6 Address: fd00:56::11 * Step-1: Setup Email Server (fd00:56::10) Update and upgrade system packages: .. code-block:: shell test1:~$ sudo apt update && sudo apt upgrade -y Install Postfix and Dovecot: .. code-block:: shell test1:~$ sudo apt install postfix dovecot-pop3d -y During Postfix setup: - Choose **Internet Site** - Set the system mail name (e.g., `mail.localdomain`) Add a test user: .. code-block:: shell test1:~$ sudo adduser testuser # Set password when prompted Enable Maildir format for mailbox storage: .. code-block:: shell test1:~$ sudo postconf -e "home_mailbox = Maildir/" test1:~$ sudo mkdir /home/testuser/Maildir test1:~$ sudo chown -R testuser:testuser /home/testuser/Maildir Configure Dovecot for POP3: Edit main configuration to enable POP3 protocol: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/dovecot.conf protocols = pop3 Set mail location: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-mail.conf mail_location = maildir:~/Maildir Restart services: .. code-block:: shell test1:~$ sudo systemctl restart postfix test1:~$ sudo systemctl restart dovecot Configure Postfix and Dovecot for IPv6 Enable IPv6 in Postfix: .. code-block:: shell test1:~$ sudo nano /etc/postfix/main.cf inet_protocols = all inet_interfaces = all Configure Dovecot to listen on IPv6 (optional): .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-master.conf Find the block for POP3 and set: .. code-block:: none service pop3-login { inet_listener pop3 { address = :: port = 110 } } Restart Dovecot: .. code-block:: shell test1:~$ sudo systemctl restart dovecot * Step-2: Allow POP3 Port Through Firewall (IPv6) Allow POP3 and SMTP traffic through `ufw`: .. code-block:: shell test1:~$ sudo ufw allow 110/tcp # POP3 test1:~$ sudo ufw allow 25/tcp # SMTP (Postfix) test1:~$ sudo ufw enable * Step-3: Setup Client and Test POP3 Over IPv6 (fd00:56::11) Install Telnet: .. code-block:: shell test2:~$ sudo apt install telnet -y Connect to POP3 server using IPv6: .. code-block:: shell test2:~$ telnet -6 fd00:56::10 110 +OK Dovecot ready. Issue POP3 commands: USER testuser PASS your_password +OK Logged in. LIST RETR 1 QUIT * Expected Results: - Telnet connects to the server over IPv6 - User is authenticated successfully - Mail list and content can be retrieved via POP3 commands - Session ends with `QUIT` command * Step-4: Wireshark Capture :download:`Download Wireshark capture ` * Troubleshooting Tips: - Monitor email logs: .. code-block:: shell test1:~$ tail -f /var/log/mail.log - Confirm Maildir exists and has proper ownership: .. code-block:: shell test1:~$ ls -ld /home/testuser/Maildir - Check Dovecot configuration: .. code-block:: shell test1:~$ sudo dovecot -n - Check Dovecot service: .. code-block:: shell test1:~$ sudo systemctl status dovecot **SMTP + POP3 Mail Server Setup Test Case (IPv6)** * Client sends mail to server over SMTP and retrieves it via POP3. * Mail stored in Maildir format on the server. * Server IP: fd00:56::10 * Client IP: fd00:56::11 * Step-1: Server Setup 1. Install Required Packages: .. code-block:: shell test1:~$ sudo apt update test1:~$ sudo apt install postfix dovecot-pop3d -y During Postfix installation: - Choose: **Internet Site** - Mail name: `mail.localdomain` 2. Configure Postfix: .. code-block:: shell test1:~$ sudo nano /etc/postfix/main.cf myhostname = mail.localdomain myorigin = /etc/mailname mydestination = localhost, localhost.localdomain, mail.localdomain mynetworks = fd00:56::/64, 127.0.0.0/8 inet_interfaces = all inet_protocols = ipv6 home_mailbox = Maildir/ Create mailname file: .. code-block:: shell test1:~$ echo "mail.localdomain" | sudo tee /etc/mailname Restart postfix: .. code-block:: shell test1:~$ sudo systemctl restart postfix 3. Create Mail User: .. code-block:: shell test1:~$ sudo adduser testuser Create Maildir for testuser: .. code-block:: shell test1:~$ sudo -u testuser maildirmake.dovecot /home/testuser/Maildir test1:~$ sudo chown -R testuser:testuser /home/testuser/Maildir 4. Configure Dovecot for POP3: a. Set mail location: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-mail.conf mail_location = maildir:~/Maildir b. Enable plaintext authentication (testing only): .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-auth.conf disable_plaintext_auth = no c. Enable POP3 protocol: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/dovecot.conf protocols = pop3 d. Enable POP3 listener on port 110: .. code-block:: shell test1:~$ sudo nano /etc/dovecot/conf.d/10-master.conf service pop3-login { inet_listener pop3 { port = 110 } } Restart Dovecot: .. code-block:: shell test1:~$ sudo systemctl restart dovecot 5. Open required firewall ports: .. code-block:: shell test1:~$ sudo ufw allow 25/tcp # SMTP test1:~$ sudo ufw allow 110/tcp # POP3 test1:~$ sudo ufw reload * Step-2: Test from Client 1. Send Mail via SMTP (client): From client machine (fd00:56::11): .. code-block:: shell test2:~$ telnet fd00:56::10 25 HELO client.localdomain MAIL FROM: RCPT TO: DATA Subject: POP3 Test Mail This is a test mail sent via SMTP for POP3 retrieval. . QUIT 2. Verify Mail Delivery on Server: .. code-block:: shell test1:~$ sudo ls /home/testuser/Maildir/new/ Check new mail file exists. 3. Retrieve Mail via POP3 (client): From client machine (fd00:56::11): .. code-block:: shell test2:~$ telnet fd00:56::10 110 +OK Dovecot ready. user testuser +OK pass +OK Logged in. list +OK 1 messages: 1 456 . retr 1 +OK [Message content appears here] . quit * Step-4: Wireshark Capture :download:`Download Wireshark capture ` .. _POP3_step6: .. tab-set:: .. tab-item:: POP3 Protocol Packet Details **POP3 COMMAND LINE Packet** .. csv-table:: :file: ./POP3/POP3_Command_Line_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **POP3 RESPONSE LINE Packet** .. csv-table:: :file: ./POP3/POP3_Response_Line_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **POP3 MESSAGE HEADER Packet** .. csv-table:: :file: ./POP3/POP3_Message_Header_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **POP3 MESSAGE BODY Packet** .. csv-table:: :file: ./POP3/POP3_Message_Body_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **POP3 TERMINATION SEQUENCE Packet** .. csv-table:: :file: ./POP3/POP3_Termination_sequence_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **POP3 AUTHENTICATION DATA Packet** .. csv-table:: :file: ./POP3/POP3_Authentication_Data_Packet.csv :widths: 10,20,30,10 :header-rows: 1 **POP3 TCP/IP HEADER Packet** .. csv-table:: :file: ./POP3/POP3_TCP_IP_Header_Packet.csv :widths: 10,20,30,10 :header-rows: 1 .. _POP3_step7: .. tab-set:: .. tab-item:: POP3 Usecases .. csv-table:: :file: ./POP3/POP3_Use_Cases.csv :widths: 10,20,30 :header-rows: 1 .. _POP3_step8: .. tab-set:: .. tab-item:: POP3 Basic Features .. csv-table:: :file: ./POP3/POP3_Features.csv :widths: 10,10,30 :header-rows: 1 .. _POP3_step9: .. tab-set:: .. tab-item:: POP3 Feature : Simple Protocol **Simple Protocol - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature1_Simple_Protocol_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step10: .. tab-set:: .. tab-item:: POP3 Feature : Email Download **Email Download - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature2_Email_Download_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step11: .. tab-set:: .. tab-item:: POP3 Feature : Offline Access **Offline Access - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature3_Offline_Access_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step12: .. tab-set:: .. tab-item:: POP3 Feature : Server Cleanup **Server Cleanup - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature4_Server_Cleanup_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step13: .. tab-set:: .. tab-item:: POP3 Feature : Limited Command Set **Limited Command Set - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature5_Limited_Command_Set_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step14: .. tab-set:: .. tab-item:: POP3 Feature : Authentication Support **Authentication Support - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature6_Authentication_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step15: .. tab-set:: .. tab-item:: POP3 Feature : Port Based Communication **Port Based Communication - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature7_Port_Based_Communication_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step16: .. tab-set:: .. tab-item:: POP3 Feature : No Folder Support **No Folder Support - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature8_No_Folder_Support_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step17: .. tab-set:: .. tab-item:: POP3 Feature : Optional TLS Encryption **Optional TLS Encryption - Testcases** .. csv-table:: :file: ./POP3/POP3_Feature9_Optional_TLS_Encryption_Test_Cases.csv :widths: 10,10,30,20 :header-rows: 1 .. _POP3_step18: .. tab-set:: .. tab-item:: Reference links * Reference links