SMTP and ncat

SMTP and ncat

Link to the course

L. Delafontaine and H. Louis, with the help of GitHub Copilot.

Based on the original course by O. Liechti and J. Ehrensberger.

This work is licensed under the CC BY-SA 4.0 license.

SMTP and ncat

Objectives

  • Refresher on networking concepts.
  • Learn electronic messaging protocols:
    • SMTP.
    • POP3.
    • IMAP.
  • Focus on the SMTP protocol.
  • Learn how to use ncat and Java to send an email to an SMTP server.
SMTP and ncat

A quick reminder about networking

More details for this section in the course material. You can find other resources and alternatives as well.

SMTP and ncat

The Internet Protocol (IP)

  • Each computer has a unique IP address
  • IPv4 addresses are limited.
  • NAT routers share IP addresses.
  • IPv6 fixes this issue.
  • IP addresses are used to route packets.
SMTP and ncat

The Domain Name System (DNS)

  • DNS maps domain names to IP addresses.
  • Example: heig-vd.ch to 193.134.223.20.
  • dig and nslookup are useful tools to query DNS servers.
SMTP and ncat

Common DNS records

DNS records map a domain name to other services/IPs:

  • NS: Name Server.
  • CNAME: Alias.
  • A: IPv4 address.
  • AAAA: IPv6 address.
SMTP and ncat

Reserved ports

  • Ports identify processes or services.
  • Analogy: an IP address is like a street address. A port is like an apartment number.
  • Ports are 16-bit unsigned numbers, maximum 65535.
  • Reserved ports: 0-1023.
  • Other ports: far west.
SMTP and ncat

Electronic messaging protocols: SMTP, POP3 and IMAP

More details for this section in the course material. You can find other resources and alternatives as well.

SMTP and ncat

Electronic messaging protocols: SMTP, POP3 and IMAP

  • Email clients are called "Mail User Agents (MUA)".
  • Email servers are called "Mail Transfer Agents (MTA)".
  • They use different protocols to communicate.
SMTP and ncat

SMTP

  • SMTP: Simple Mail Transfer Protocol.
  • Uses TCP port 25 (unencrypted) or 465 (encrypted).
  • Used to send emails.
SMTP and ncat

POP3

  • POP3: Post Office Protocol.
  • Uses TCP port 110 (unencrypted) or 995 (encrypted).
  • Used to retrieve emails from a server.
SMTP and ncat

IMAP

  • IMAP: Internet Message Access Protocol.
  • Uses TCP port 143 (unencrypted) or 993 (encrypted).
  • Used to retrieve emails from a server.
  • Much more powerful than POP3 (synchronization, ...).
SMTP and ncat

More details for this section in the course material. You can find other resources and alternatives as well.

SMTP and ncat
  • MX: Mail eXchange - Specifies the mail server responsible for a domain name.
  • TXT: Store any text-based information. Used for SPF records, for email authentication.
SMTP and ncat

Security concerns and spam

More details for this section in the course material. You can find other resources and alternatives as well.

SMTP and ncat

Security concerns and spam

  • SMTP is old and insecure.
  • Easy to spoof and forge emails.
  • Hard to maintain.
  • ➡️ Your email server can be used for spam and can be blocked.
  • ➡️ We will use a mock server to simulate an email server.
SMTP and ncat

A focus on the SMTP protocol

More details for this section in the course material. You can find other resources and alternatives as well.

SMTP and ncat

A focus on the SMTP protocol

  • SMTP is a text-based protocol.
  • Messages are sent by the client to the server.
  • The server responds with a status code.
  • The client can send the next command.
SMTP and ncat
SMTP and ncat

ncat

More details for this section in the course material. You can find other resources and alternatives as well.

SMTP and ncat

ncat

  • ncat is network utility for reading from and writing to network connections.
  • It is used to connect to a remote server (SMTP, HTTP, ...).
  • We will use it to interact with a SMTP server.
SMTP and ncat

Questions

Do you have any questions?

SMTP and ncat

Practical content

SMTP and ncat

What will you do?

  • Install and configure ncat.
  • Start a SMTP server with Docker Compose.
  • Send an email with ncat to the SMTP server.
  • Send an email with Java to the SMTP server.
SMTP and ncat

Now it's your turn!

  • Read the course material.
  • Do the practical content.
  • Ask questions if you have any.

➡️ Find the course on GitHub.

Do not hesitate to help each other! There's no need to rush!

SMTP and ncat

Finished? Was it easy? Was it hard?

Can you let us know what was easy and what was difficult for you during this course?

This will help us to improve the course and adapt the content to your needs. If we notice some difficulties, we will come back to you to help you.

➡️ GitHub Discussions

You can use reactions to express your opinion on a comment!

SMTP and ncat

Sources