Emails

How to Setup Sendmail

Authenticate Sendmail so signup and system emails reach the inbox: From address, SPF, DKIM, DMARC, MX, reverse DNS, and how to test your score.

How to Setup Sendmail

Choosing Sendmail in the admin panel is only half the job. The server can send mail, but Gmail, Outlook, and others still need proof that your domain is allowed to send. That proof is DNS (SPF, DKIM, DMARC, MX) plus reverse DNS on your server IP.

This guide uses placeholders. Replace them with your values:

Placeholder Example
Your domain example.com
From address support@example.com
Mail hostname mail.example.com
Server public IPv4 203.0.113.10

DNS changes are made at whoever hosts your domain DNS (Cloudflare, Namecheap, your registrar, etc.). The record types and values are the same everywhere. Only the control panel looks different.

Step 1 — Set the From address in XFile Ultra

1. Open Admin → Settings → Main

2. Set Email from address to an address on your domain, for example support@example.com

3. Do not use a Gmail, Yahoo, or Outlook address as From when using Sendmail

4. Fill Site contact e-mail too (test emails are sent there)

Save settings.

Step 2 — Turn on Sendmail and send a first test

1. Open Admin → Settings → Main → Email delivery

2. Choose Sendmail

3. Save

4. Click Send test email

If the test fails with “sendmail not found”, install Postfix (or another sendmail-compatible MTA) on the server using your install docs, then try again.

A successful test only means the server accepted the message. It can still land in spam until the steps below are done.

Step 3 — Create a mail hostname (A record)

Create a DNS A record for the hostname you will use for mail:

Type Name Content / value Proxy
A mail your server public IPv4 (example: 203.0.113.10) DNS only (not proxied)

Full name becomes mail.example.com.

Cloudflare: set the cloud to gray (DNS only). Never orange-proxy mail hostnames.

Other DNS panels: there is usually no proxy toggle — just create the A record.

Step 4 — Set reverse DNS (PTR)

Reverse DNS maps your server IP → mail hostname.

1. Open your VPS / hosting panel (the place that owns the IP, not Cloudflare)

2. Find Reverse DNS, PTR, or rDNS for your server IPv4

3. Set it to mail.example.com (must match the A record from Step 3)

Without PTR, many providers reject or spam-folder your mail even if SPF looks fine.

Check later with:

dig +short -x YOUR.SERVER.IP

You want: mail.example.com.

Step 5 — Add SPF

SPF lists which servers may send mail for your domain.

At your DNS provider, add a TXT record on the root domain (@ / example.com):

Type Name Content Proxy
TXT @ v=spf1 ip4:YOUR.SERVER.IP -all DNS only

Example if your IP is 203.0.113.10:

v=spf1 ip4:203.0.113.10 -all

Rules:

  • Only one SPF TXT on the domain (do not create two SPF records)
  • Use your real server IPv4
  • -all means “only what is listed here”

Check:

dig +short TXT example.com

Step 6 — Add DMARC

DMARC tells receivers what to do when SPF/DKIM fail. Start in monitor mode.

Type Name Content Proxy
TXT _dmarc v=DMARC1; p=none; rua=mailto:support@example.com DNS only

Keep p=none at first. Later you can tighten to quarantine or reject when scores look good.

Check:

dig +short TXT _dmarc.example.com

Step 7 — Add an MX record

Receivers (and tools like mail-tester) expect an MX for your domain, even if you mostly send mail.

Type Name Mail server / value Priority Proxy
MX @ mail.example.com 10 DNS only

This does not create a full mailbox product by itself. It only publishes “this domain’s mail server is mail.example.com”.

Check:

dig +short MX example.com

You want something like: 10 mail.example.com.

Step 8 — Install and configure DKIM on the server (OpenDKIM)

DKIM cryptographically signs each message. SPF alone is not enough for good inboxing.

These commands are for a typical Ubuntu/Debian server with Postfix. Run them as root. Replace example.com and the IP with yours.

8.1 Install packages

apt-get update
apt-get install -y opendkim opendkim-tools

8.2 Create the domain key

DOMAIN="example.com"
SELECTOR="mail"
KEYDIR="/etc/opendkim/keys/${DOMAIN}"

mkdir -p "$KEYDIR"
opendkim-genkey -b 2048 -d "$DOMAIN" -D "$KEYDIR" -s "$SELECTOR" -v

chown -R opendkim:opendkim /etc/opendkim
chmod 700 /etc/opendkim/keys
chmod 700 "$KEYDIR"
chmod 600 "${KEYDIR}/${SELECTOR}.private"
chmod 644 "${KEYDIR}/${SELECTOR}.txt"

8.3 OpenDKIM tables

DOMAIN="example.com"
SELECTOR="mail"
KEYDIR="/etc/opendkim/keys/${DOMAIN}"

cat > /etc/opendkim/KeyTable <<EOF
${SELECTOR}._domainkey.${DOMAIN} ${DOMAIN}:${SELECTOR}:${KEYDIR}/${SELECTOR}.private
EOF

cat > /etc/opendkim/SigningTable <<EOF
*@${DOMAIN} ${SELECTOR}._domainkey.${DOMAIN}
EOF

cat > /etc/opendkim/TrustedHosts <<EOF
127.0.0.1
localhost
::1
YOUR.SERVER.IP
mail.${DOMAIN}
*.${DOMAIN}
EOF

chown opendkim:opendkim /etc/opendkim/KeyTable /etc/opendkim/SigningTable /etc/opendkim/TrustedHosts

Replace YOUR.SERVER.IP with your real IPv4 before saving.

8.4 OpenDKIM main config

cat > /etc/opendkim.conf <<'EOF'
Syslog                  yes
SyslogSuccess           yes
LogWhy                  yes
Canonicalization        relaxed/simple
Mode                    sv
SubDomains              no
AutoRestart             yes
AutoRestartRate         10/1M
Background              yes
DNSTimeout              5
SignatureAlgorithm      rsa-sha256
Socket                  inet:8891@localhost
PidFile                 /run/opendkim/opendkim.pid
UserID                  opendkim:opendkim
UMask                   007
KeyTable                /etc/opendkim/KeyTable
SigningTable            refile:/etc/opendkim/SigningTable
ExternalIgnoreList      /etc/opendkim/TrustedHosts
InternalHosts           /etc/opendkim/TrustedHosts
OversignHeaders         From
EOF

8.5 Connect Postfix to OpenDKIM

DOMAIN="example.com"

postconf -e "myhostname = mail.${DOMAIN}"
postconf -e "mydomain = ${DOMAIN}"
postconf -e "smtpd_milters = inet:localhost:8891"
postconf -e "non_smtpd_milters = inet:localhost:8891"
postconf -e "milter_default_action = accept"
postconf -e "milter_protocol = 6"

mkdir -p /run/opendkim
chown opendkim:opendkim /run/opendkim

systemctl enable opendkim
systemctl restart opendkim
systemctl reload postfix || systemctl restart postfix

Confirm OpenDKIM is listening:

ss -lntp | grep 8891
systemctl is-active opendkim postfix

Step 9 — Publish the DKIM public key in DNS

Show the public key:

cat /etc/opendkim/keys/example.com/mail.txt

Or build a single-line value:

python3 - <<'PY'
from pathlib import Path
import re
raw = Path("/etc/opendkim/keys/example.com/mail.txt").read_text()
parts = re.findall(r'"([^"]*)"', raw)
print("".join(parts))
PY

Add this DNS record:

Type Name Content Proxy
TXT mail._domainkey the full v=DKIM1; … p=… string from the command above DNS only

Cloudflare tip: paste the whole string as one TXT value. If the panel splits long TXT records, that is normal — receivers still see one key.

Check:

dig +short TXT mail._domainkey.example.com

You should see v=DKIM1 and a long p= public key.

Step 10 — Checklist of what you should have

Record / setting Example Proxied?
A mail mail.example.com → server IP No (DNS only)
PTR / reverse DNS server IP → mail.example.com set in hosting panel
TXT SPF on @ v=spf1 ip4:SERVER.IP -all No
TXT DMARC _dmarcv=DMARC1; p=none; … No
MX on @ 10 mail.example.com No
TXT DKIM mail._domainkeyv=DKIM1; … No
App From support@example.com
App mode Sendmail

Step 11 — Test your score

Quick test from the admin panel

1. Put your personal inbox (Gmail/Outlook) in Site contact e-mail, or keep contact email and use that inbox

2. Send test email

3. Check inbox and spam

4. In Gmail: open the message → three dots → Show original → look for SPF: PASS and DKIM: PASS

Score test (recommended)

1. Open https://www.mail-tester.com/

2. Copy the unique address shown on the page (it looks like test-xxxxxx@srv1.mail-tester.com)

3. In XFile Ultra, paste that address into Site contact e-mail

4. Save settings

5. Click Send test email

6. Back on mail-tester, click to check your score

Aim for a high score (about 8–10 / 10).

If mail-tester complains about a missing MX, finish Step 7 and retest with a new mail-tester address (old ones expire).

Where the mail-tester address goes

The admin Send test email button sends to Site contact e-mail. That is where you paste the mail-tester address. You do not need a real mailbox app for support@example.com just to send tests.

Common problems

Test sends, but mail is in spam

SPF/DKIM/DMARC/PTR incomplete, or From address is not on your domain.

DKIM fails in “Show original”

DNS TXT for mail._domainkey missing/wrong, or OpenDKIM not signing (check journalctl -u opendkim for DKIM-Signature field added).

SPF fails

Wrong IP in SPF, or From domain does not match the domain you authenticated.

“No MX behind your domain”

Add the MX record from Step 7.

Orange cloud / proxied A record for mail

Turn proxy off for mail hostnames. Mail must hit your server IP directly.

Related