Recently, while experimenting with WP Mail SMTP, I discovered that most SMTP services using a custom domain are paid. Since I didn’t want to spend money, I had to use Gmail SMTP instead. However, the drawback is that all outgoing emails show my Gmail address as the sender.
If you want to send emails with your own domain name (e.g., you@yourdomain.com
), the only real solution is to set up your own mail server. Although control panels like aaPanel can configure a full mail server, in many cases we don’t need a complex setup. For a WordPress site, a lightweight SMTP service is enough to handle notification emails, while incoming emails can still be managed by a free business email provider for reliability.

Now let’s build a lightweight mail system that is dedicated to SMTP sending only. We’ll configure Postfix on a VPS, enable DKIM signing, set up the proper SPF record, and walk through the complete process of sending WordPress notification emails successfully.
The goal of this setup is clear:
- Send only (no incoming mail handling)
- SMTP only (no IMAP or POP3)
- No third-party email services required
Why Choose Manual Configuration Instead of aaPanel Mail Server?
The aaPanel mail server is designed to provide a complete email solution, including SMTP (sending) and IMAP/POP3 (receiving). However, my domain’s email is already managed by NetEase free business email, which handles all day-to-day sending and receiving.
Using aaPanel’s mail server would automatically add _domainkey
DNS records for DKIM. Since the NetEase business email already has DKIM records with the same prefix, the two systems cannot coexist. Manual configuration allows full control over the DKIM selector and DNS prefix, avoiding conflicts.
Our goal is very clear: we only need a lightweight SMTP server on the VPS. This way, WordPress can send emails reliably, without affecting the existing domain mailbox. It achieves perfect coexistence between the VPS SMTP server and the NetEase domain email service.
Ensure Port 25 Is Open on Your VPS
To send emails directly from your VPS using Postfix, port 25 must be open. This is the standard SMTP port for sending mail to other servers.
⚠️ Important: Some VPS providers block port 25 by default to prevent spam. If port 25 is blocked, you cannot send emails directly from your VPS and must rely on a third-party SMTP service instead.
Installing and Configuring Postfix SMTP on Your VPS
1、Install Postfix
On Ubuntu/Debian:
sudo apt update && sudo apt upgrade
sudo apt install postfix
During the installation, Postfix will prompt you to select a configuration type. Choose Internet Site and enter your domain name (e.g., thuszen.com
).
2、Configure Postfix
Edit the main Postfix configuration file /etc/postfix/main.cf
and add the following settings:
# TLS parameters
smtp_tls_CApath=/etc/ssl/certs
smtp_tls_security_level=may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
myhostname = mail.thuszen.com
myorigin = thuszen.com
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
inet_interfaces = loopback-only
inet_protocols = all
Explanation:
- myhostname: Set this to your mail server subdomain (e.g.,
mail.thuszen.com
). - myorigin = thuszen.com: The default domain for outgoing emails (e.g.,
user@thuszen.com
). - mynetworks: Restrict sending to the local network only, preventing abuse.
- inet_interfaces = loopback-only: Specify which network interfaces the server listens on (loopback-only means only the local loopback interface).
- inet_protocols = all: Specify which network protocols to support (both IPv4 and IPv6).
Install DKIM to Improve Email Deliverability
1、Install OpenDKIM:
sudo apt install opendkim opendkim-tools
2、Generate the DKIM key pair
It is recommended to create a directory for your domain under /etc/opendkim/keys/
:
sudo mkdir -p /etc/opendkim/keys/thuszen.com
Generate the key using wpmail
as the selector name (you can customize it to avoid conflicts with NetEase Mail):
cd /etc/opendkim/keys/thuszen.com
sudo opendkim-genkey -s wpmail -d thuszen.com
This will generate two files:
wpmail.private
→ the private key (used by the server for signing)wpmail.txt
→ the public key (to be added as a DNS TXT record)
Configure OpenDKIM with Postfix
Add the following to /etc/opendkim.conf
:
Syslog yes
UMask 007
Mode sv
Canonicalization relaxed/simple
SubDomains no
Selector default
Domain thuszen.com
KeyFile /etc/opendkim/keys/thuszen.com/default.private
Socket inet:8891@localhost
Add the following lines to /etc/postfix/main.cf
:
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891
Configure DNS Records
A Record:
- Host/Name: mail
- Type: A
- Value: Your VPS public IP address
SPF Record (to improve deliverability and prevent emails from being marked as spam):
- Host/Name: @
- Type: TXT
- Value (send-only via your VPS):v=spf1 ip4:YOUR_VPS_IP ~all
- Value (coexisting with NetEase Business Email):v=spf1 ip4:209.55.108.38 include:spf.163.com -all
TXT Record:
- Host/Name:
wpmail._domainkey
- Type: TXT
- Value: Copy the content inside the parentheses from the
wpmail.txt
file. Do not include the double quotes twice, and keep the slashes as they are.
_dmarc Record:
NetEase Business Email does not allow modifying the _dmarc
record, so it is not configured.
If you are not using another email provider, you can configure a TXT record like this:v=DMARC1; p=none; rua=mailto:dmarc@yourdomain.com
At this point, WordPress can successfully send notification emails. Comment notifications, plugin updates, and other automated alerts are all delivered properly.
I have four websites hosted on the same VPS, and each can send notifications using its own domain. For example, emails can appear from or . This setup is not limited to the domain configured in Postfix, giving each WordPress site the flexibility to use its own sender address.wordpress@websitesoez.comwordpress@oddbbo.com
.
You can also use plugins to manage outgoing emails, such as WP Mail SMTP:
- SMTP Host: localhost
- Encryption: None
- SMTP Port: 25
- Auto TLS: Enabled
- Authentication: Disabled
Conclusion
During testing, I found that NetEase Business Email cannot receive emails sent from the VPS. The mail logs show:
451 4.3.2 Internal server error
Postfix successfully delivered the email to NetEase’s server, but it was rejected. The recipient inbox does not receive the email, and no bounce message is generated.
Emails sent to 163.com addresses and Alibaba Business Email worked normally. Attempts to contact NetEase support regarding this issue were unsuccessful.
⚠️ Note for Gmail users:
If you want to send emails to Gmail, you must set up a reverse DNS (PTR record) for your VPS. Otherwise, Gmail will reject your messages with:550-5.7.25
host gmail-smtp-in.l.google.com[142.251.2.27] said:
550-5.7.25 [209.54.104.38] The IP address sending this message does not
have a 550-5.7.25 PTR record setup, or the corresponding forward DNS entry
does not 550-5.7.25 match the sending IP. As a policy, Gmail does not
accept messages 550-5.7.25 from IPs with missing PTR records. For more
information, go to 550-5.7.25
Finally, you can use mail-tester.com to check the deliverability score of emails sent from your VPS.