Skip to content

Mail Server Basics

Mail Server common knowledge

TermDescription
Domain nameAs the unique identifier of an email server, the domain name is used to identify one or more IP addresses. For example: aapanel.com.
MX record
(Mail Exchange)
The MX record specifies the domain name of the mail server responsible for receiving email delivery. The sending mail server uses the MX record to determine the route of the email. For example, the MX record of aapanel.com points to mail.aapanel.com .
A recordThe A record maps a domain name to an IPv4 address. It specifies the server IP address associated with the domain. For instance, the A record of mail.aapanel.com points to 1.2.3.4 .
SPF
(Sender Policy Framework)
SPF is a mechanism to verify if the sender is authorized to send emails. By setting up SPF records in DNS, it specifies which IP addresses are allowed to send emails for a specific domain.
DKIM
(DomainKeys Identified Mail)
DKIM is an email authentication mechanism that ensures the integrity and authenticity of emails through digital signatures. Receiving mail servers use DKIM to verify the source of the email.
DMARC
(Domain-based Message Authentication, Reporting, and Conformance)
DMARC combines SPF and DKIM, providing a mechanism to authenticate the source of emails and specifying how receiving mail servers should handle emails that fail authentication.
PTR record
(Pointer)
The PTR record is used for reverse DNS lookup of IP addresses to domain. It helps verify the identity of mail servers, ensuring that their IP address matches the domain name. Generally set up at the network provider or server provider.
SMTP
(Simple Mail Transfer Protocol)
The protocol used for sending emails, typically using 25 port (unencrypted) or 587 port (encrypted with STARTTLS).
25 Port25: Primarily used for SMTP transmission.
587 Port587: Used for secure email sending (SMTP with STARTTLS), recommended for client-to-server connections.
465 Port465: Used for SMTPS (SMTP over SSL).
110 Port110: Used for the POP3 protocol, receiving emails over an unencrypted connection.
995 Port995: Used for POP3S (POP3 over SSL), an encrypted email receiving connection.
143 Port143: Used for the IMAP protocol, receiving emails over an unencrypted connection.
993 Port993: Used for IMAPS (IMAP over SSL), an encrypted email receiving connection.
Email ClientsSuch as Outlook, Thunderbird, etc., used for sending and receiving emails.

Regarding Port 25

  • Currently, mail servers can only communicate via port 25; it's not possible to directly use other ports for communication.

    1. Submit a ticket to the server provider to open port 25.

    2. Use an SMTP relay server for forwarding: SMTP Relay

  • How to check if the outbound direction of port 25 on the server is open?

    Execute the following commands on the server to check:

    • Redhat/CentOS:
      yum install telnet -y && telnet gmail-smtp-in.l.google.com 25
    • Debian/Ubuntu:
      apt install telnet -y && telnet gmail-smtp-in.l.google.com 25

    More test addresses: telnet smtp.qq.com 25 , telnet smtp.163.com 25

    • If port 25 is blocked, the output will look like this, and it will continuously show as connecting:

      You can press Ctrl+C to exit

      alt text

    • If not blocked, the output will look like this:

      You can type quit to exit

      alt text

  • How to handle if port 25 is occupied?

    1. Use the command to check the process occupying the port:
      ss -tulnp | grep :25
    2. Common programs that occupy port 25: Exim, Postfix, Sendmail
    3. If you do not need the program (e.g., you are not using Exim or Postfix to send emails), you can directly stop and disable it. Stop the program based on its name:
      systemctl stop exim && systemctl disable exim
      Or
      systemctl stop postfix && systemctl disable postfix
      Or
      service sendmail stop && chkconfig sendmail off

Example

  • Domain name: aapanel.com

  • MX record: aapanel.com MX 10 mail.aapanel.com

  • A record: mail.aapanel.com A 1.2.3.4

  • SPF record: aapanel.com TXT "v=spf1 +a +mx +ip4:1.2.3.4 -all"

  • DKIM record: default TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqBgQC..."

  • DMARC record: _dmarc TXT "v=DMARC1; p=reject; rua=mailto:[email protected]"

  • PTR record: 4.3.2.1.in-addr.arpa. PTR mail.aapanel.com

    PTR record: Generally set up at the network provider or server provider.