vi

Postfix Mail Server: Email Self-Hosted Tren VPS

Tu host email server cho phep ban kiem soat hoan toan email cua doanh nghiep va tranh phu thuoc vao Google Workspace hoac Microsoft 365 - nhung dich vu doc email de phuc vu quang cao va co the bi yeu cau cung cap noi dung. Postfix la mail transfer agent chuan industry, ket hop voi Dovecot (IMAP/POP3), Rspamd (anti-spam) va OpenDKIM tao nen stack email production hoan chinh. AnubizHost cung cap VPS Iceland voi reverse DNS sach va IP khong blacklist phu hop chay mail server. Bai viet nay huong dan thiet lap end-to-end.

Need this done for your project?

We implement, you ship. Async, documented, done in days.

Start a Brief

Vi Sao Tu Host Email Mac Du Phuc Tap

Google Workspace va Microsoft 365 don gian, nhung danh doi quyen rieng tu va chu quyen. Google quet email de phuc vu quang cao (dieu nay van con tranh cai du Google da claim ngung). Microsoft luu email tren cloud co the bi yeu cau cung cap qua thoa thuan phap ly xuyen bien gioi.

Postfix self-hosted tren VPS Iceland mang lai 4 loi the:

  • Khong ai doc email cua ban: Email luu encrypted at rest tren VPS rieng. Chi co SSH key cua ban moi mo duoc.
  • Iceland jurisdiction: Yeu cau cung cap email cua chinh quyen khac kho thuc thi do luat bao ve thu tu chau Au.
  • Email rieng cho moi du an: [email protected], [email protected] - tat ca tren cung server, khong tang phi theo user.
  • Catch-all va alias linh hoat: Tao alias khong gioi han, dung email tam thoi cho moi dich vu de chong tracking.

AnubizHost VPS Iceland co reverse DNS sach va IP khong nam trong DNSBL phu hop chay mail server. Goi Pro voi 4GB RAM phu hop cho mail server phuc vu 5-20 user va vai nghin email moi ngay.

Truoc khi bat dau, dam bao co domain rieng va co the chinh DNS record. Cau hinh DNS quan trong: A record cho mail.domain.com, MX record cho domain.com, PTR record (reverse DNS) phai duoc set boi AnubizHost - lien he support de set.

Cai Dat Postfix + Dovecot + OpenDKIM

Cai dat goi can thiet tren Debian 12:

apt update && apt install -y postfix postfix-mysql dovecot-core dovecot-imapd \
  dovecot-pop3d dovecot-mysql opendkim opendkim-tools rspamd certbot

Khi cai postfix, chon "Internet Site" va nhap domain (vd yourdomain.com).

Cau hinh Postfix: Sua /etc/postfix/main.cf:

myhostname = mail.yourdomain.com
mydomain = yourdomain.com
myorigin = $mydomain
inet_interfaces = all
mydestination = localhost
relay_domains = $mydestination
home_mailbox = Maildir/
# TLS
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.yourdomain.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.yourdomain.com/privkey.pem
smtpd_use_tls = yes
smtpd_tls_security_level = may
smtp_tls_security_level = may
# Anti-spam helpers
smtpd_helo_required = yes
smtpd_helo_restrictions = permit_mynetworks,reject_invalid_helo_hostname,permit
smtpd_sender_restrictions = permit_mynetworks,reject_unknown_sender_domain,permit
smtpd_recipient_restrictions = permit_mynetworks,reject_unauth_destination,reject_rbl_client zen.spamhaus.org,permit

Tao DKIM key voi OpenDKIM:

mkdir -p /etc/opendkim/keys/yourdomain.com
cd /etc/opendkim/keys/yourdomain.com
opendkim-genkey -d yourdomain.com -s mail
chown opendkim:opendkim mail.private
# DNS record can them:
cat mail.txt  # Copy noi dung len DNS provider:
# mail._domainkey IN TXT "v=DKIM1; k=rsa; p=..."

SPF va DMARC DNS records (them tai DNS provider):

yourdomain.com.   TXT  "v=spf1 mx -all"
_dmarc.yourdomain.com.  TXT  "v=DMARC1; p=quarantine; rua=mailto:[email protected]"

Khoi dong lai postfix va opendkim. Test bang cach gui email den [email protected] va doc bao cao tra ve - phai pass SPF, DKIM, va DMARC.

Anti-Spam, IMAPS Va Webmail Production

Rspamd cho anti-spam: Rspamd moi va manh hon SpamAssassin. Sau khi cai, sua /etc/postfix/main.cf them:

smtpd_milters = inet:localhost:11332,inet:localhost:8891
non_smtpd_milters = $smtpd_milters
milter_protocol = 6
milter_default_action = accept

Cong 11332 la Rspamd, 8891 la OpenDKIM. Rspamd web UI tai http://vps-ip:11334 hien thi spam score va cho phep training Bayesian filter.

Dovecot IMAPS: Sua /etc/dovecot/conf.d/10-mail.conf:

mail_location = maildir:~/Maildir
mail_uid = vmail
mail_gid = vmail

Trong 10-ssl.conf:

ssl = required
ssl_cert = 

Trong 10-master.conf, bat cong 993 (IMAPS) va 587 (Submission). DONG cong 110 (POP3 plaintext) va 143 (IMAP plaintext) - chi cho phep TLS.

Roundcube webmail:

apt install -y roundcube roundcube-mysql

Cau hinh Roundcube tro toi localhost:993 cho IMAP va localhost:587 cho SMTP. Su dung Caddy reverse proxy de expose Roundcube qua HTTPS tai mail.yourdomain.com/webmail.

Monitoring va backup:

  • mailgraph: Theo doi luu luong email, spam rate.
  • Backup Maildir hang ngay: Rsync sang VPS thu hai, ma hoa truoc khi gui di.
  • Check blacklist hang tuan: mxtoolbox.com xac minh IP cua VPS khong nam trong DNSBL.

Voi stack nay, mail server tren AnubizHost VPS Iceland phuc vu doanh nghiep voi do tin cay cao, bao mat phap ly va deliverability tot - day la giai phap email production day du voi chi phi thap hon nhieu so voi Google Workspace dai han.

Why Anubiz Host

100% async — no calls, no meetings
Delivered in days, not weeks
Full documentation included
Production-grade from day one
Security-first approach
Post-delivery support included

Ready to get started?

Skip the research. Tell us what you need, and we'll scope it, implement it, and hand it back — fully documented and production-ready.

Anubiz Chat AI

Online