I see some people on the forum wondering why sending emails on aaPanel to Gmail is getting sent to the spam folder.
I confirm that aaPanel is completely error-free, Mail Server works perfectly and securely
Sending mail straight to inbox is not aaPanel's job, it is your responsibility, and the IPS you choose.
Ok, let's get started.
1. You need to choose an IPS that supports rDNS and open port 25
Reverse DNS is very important for your mail to go straight to the inbox, it is a common standard of gmail, the simple concept is like "SSL of domain name", helping gmail filter understand clearly where the IP you send from.
You can create a support ticket directly to that IPS's technical department instead of chatting with the sales staff, sometimes they say "rDNS support available" even though they don't know what it is 🙂
2. Requires opening port 25 for VPS, server
This is a mandatory condition when sending mail to gmail, most IPS block port 25 to prevent users from sending mail to many different VPS and servers.
You can request to open port 25 via support ticket, be specific and state the reason why you want to open them, and remember that not all IPS are generous enough to open port 25 for you.
3. Operations on VPS, Server
Once you have pointed rDNS and opened port 25, you are almost 99.9% sure that gmail will not flag your mail as spam anymore.
However, you must fully control your VPS by setting up hostname, turning off IPv6, pointing SLL for hostname to postfix on aaPanel,..
3.1. Set up Hostname
Please enter the command
hostnamectl set-hostname name-host-for-you
In which, name-host-for-you is the hostname you want to set, for example smtp.domain.com, don't forget to point your domain name A record to the IP of VPS, server
3.2. Disable IPv6
Open the sysctl.conf file
sudo nano /etc/sysctl.conf
Add 3 lines
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
Apply configuration
sudo sysctl -p
Remember to reapply the configuration after reboot, that's my experience, maybe I'm OCD, but just mail it to your inbox 🙂
4. Install aaPanel
After installing aaPanel (LAMP), please install the Redis and Mail Server plugins.
4.1. Add password for Redis
Optimization -> requirepass -> enter random password
4.2. Open Mail Server and Install
Just install as instructed.
4.3. Add Hostname and Request SSL
Add the domain name you selected as hostname previously (eg: smtp.domain.com) to aaPanel and request free SSL)
4.4. Set up postfix
Open Mail Server -> Service Status -> Config Postfix
Find line
# TLS parameters
smtpd_tls_cert_file = xxxx
smtpd_tls_key_file = xxxx
Replace it with the SSL just requested from the hostname
# TLS parameters
smtpd_tls_cert_file = /www/server/panel/vhost/ssl/smtp.domain.com/fullchain.pem
smtpd_tls_key_file = /www/server/panel/vhost/ssl/smtp.domain.com/privkey.pem
Remember to restart Postfix after saving.
5. Add domain name to Mail Server
Finally, just add the domain name and records according to aaPanel's instructions and you will have a free mail server and 99.9% of it will go straight to your google inbox.
Some important notes
- You should check the IP of VPS, server is in blacklist like spamhaus,.. or not (can use MXToolbox)
- This guide only applies to Unbutu servers.
- You should use port 587 (TLS) so that other domains can still access the inbox (if there is only 1 VPS and many domains).
- Finally, this is the knowledge that I spent time and money to learn, 99.9% guaranteed to be successful, if you have difficulty, you can contact me immediately so I can guide you further (Free if you using aaPanel).
Don't be foolish if you want to use this function to send marketing emails, IPS all have limits for sending emails every hour, every day, if you exceed the limit your service may be deleted, or worse you will have to pay compensation and be prosecuted for legal responsibility.