When sending an email, Postfix uses the system's resolver (that is, the DNS client, which can query domain information from the DNS server) to obtain DNS information. When receiving a mail, the DNS of your domain must provide delivery information (MX or a record) for external queries so that other MTA can find your Postfix server.
Influence of DNS on the sender Program
The smtp mda of Postfix must be able to obtain Mx and a records to determine the Host Name and IP address. That is to say, in the sender program, Postfix requires at least two DNS queries. The first is to get the MX host name, and the other is to get the IP address of the host name. Because Postfix uses the resolver of the operating system to access the DNS server, the system running Postfix must be able to access at least one DNS server. Although most systems running Postfix usually run DNS servers, this is not necessary.
If you suspect that your system cannot properly query DNS information, you can find out the problem through three command line tools: NSlookup, dig, and host. Most Unix systems should install these three tools. You can use these tools to identify all types of data records for a specific domain, including MX records that allow Postfix to send mail to the correct host.
The DNS issue may be caused by a system error in which the Postfix is located, or the DNS server of the target domain is not properly set. When looking for the cause of the problem, you must keep in mind that Postfix always first queries the MX record and then queries the record. Even if you can find out the IP address of the domain name, if the domain does not provide MX information, Postfix may not be able to send emails for the first time.
Configuration File Options
When a mail is delivered, the Postfix identifies all MX resource records of the target domain from the DNS system, and then sorts the records based on the priority value. After the Postfix is successfully connected to the recipient's SMTP server, the recipient will use the status code to answer the requirements of smtp mda. A status code between the 2XX range indicates that the request is accepted. If a status code within the 4xx range is returned, it indicates that the other party has encountered a temporary error. If the status code is within the 5xx range, indicates a permanent problem.
PTR record
To prevent spam, many SMTP servers require that the client IP address be able to identify valid PTR resource records. Therefore, the IP address of your Postfix system must have a PTR record pointing to the specified Postfix host name in the DNS system so that all SMTP servers will accept the emails you sent.
Influence of DNS on email receiving program
To enable Postfix to receive emails from a specific domain, the host name running Postfix must be listed in the MX record of the domain, and the Postfix must also be set to be able to receive emails from the domain. Postfix can receive emails from three domains: local domain, relay domains, and virtual domains ). The virtual domain may use virtual aliases or virtual mailboxes ). Each domain must be listed in a specific Postfix parameter for validity.
Domain type parameters
Local mydestination
Relay_domains
Virtual mailbox virtual_mailbox_domains
Virtual alias virtual_alias_domains
The same domain name cannot be listed in different parameters at the same time. If the Postfix finds the same domain in two parameters, it will issue a warning. If you see an error message like "mail for example.com loops back to myself" in the log file, it is usually because your Postfix server is listed in the MX list of a domain, however, the Postfix is not set to accept emails for this domain.
FAQs
Problems caused by improper DNS settings usually do not have immediate visibility. You can only analyze the error information in the log file.
"Mail for domain loops back to myself" (emails in a domain are bypassed by myself)
Among all DNS errors, this is probably the most common. The problem is that your Postfix server is listed in the MX list of a domain, but you didn't let the Postfix know that it is the mail terminal of the domain. Therefore, the solution is to list the domain in the mydestination parameter, or set it to a virtual domain or a forwarding domain. If your Postfix server is listed on a porxy or NAT device, it may not be aware that it is a domain's MX host. In this case, you must add the IP address of the proxy system to the proxy_interfaces parameter.
"Host found but no data record of requested type" (the host can be found, but no data type is specified for record)
The domain name cannot find the MX record in the DNS database, and the domain name itself does not have a record. You have to contact the DNS administrator for the domain to solve the problem. If you are the database administrator of the DNS domain name, make sure that the host name of your email server is indeed listed in the MX record of the domain.
"No MX host for domain has a valid a record"
The domain's DNS database has MX records, but the IP address corresponding to the MX host name cannot be found. You must contact the DNS administrator to solve the problem. For your own domain, make sure that each host name listed in the MX record has a valid and correct a record.
"Host not found, try again"
No meaningful results can be found from the DNS system. It may be caused by DNS Serer disconnection, denial of service, or even failure. If you can confirm that the DNS server of the domain is operating correctly, the problem may be the network, or the resolver of the Postfix server system is not properly set. For the last possibility, check the/etc/nsswitch. conf and/etc/resolv. conf configuration files of the system.