You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 16.04服务器Postfix MTA发送邮件进垃圾箱问题求助

Troubleshooting Postfix Emails Going to Spam on Ubuntu 16.04

Hey Martin, let's figure out why your Postfix-sent emails are landing in spam instead of the inbox. Since your domain isn't blacklisted and this worked smoothly on another server before, the issue is almost certainly tied to missing authentication records or misconfigured Postfix settings on your current Ubuntu 16.04 box. Let's break this down into actionable steps:

1. Critical Email Authentication Records (SPF, DKIM, DMARC)

These are non-negotiable for modern email delivery—your old server probably had these set up, but your new one might not:

  • SPF Record: Add a TXT record to your domain's DNS that explicitly allows your server's IP to send emails on its behalf. Example:
    v=spf1 ip4:YOUR_SERVER_IP -all
    
    The -all tells mail servers to reject any emails claiming to be from your domain that don't come from the listed IP.
  • DKIM Signing: Postfix doesn't enable DKIM by default, so you'll need to set it up with opendkim:
    1. Install it: sudo apt-get install opendkim opendkim-tools
    2. Generate DKIM keys for your domain: sudo opendkim-genkey -d yourdomain.com -s mail
    3. Add the generated public key as a TXT record (mail._domainkey.yourdomain.com) in your DNS.
    4. Configure Postfix to hook into opendkim by adding these lines to main.cf:
      milter_default_action = accept
      milter_protocol = 6
      smtpd_milters = inet:localhost:8891
      non_smtpd_milters = inet:localhost:8891
      
  • DMARC Record: Add a TXT record (_dmarc.yourdomain.com) to enforce authentication checks. A basic example:
    v=DMARC1; p=quarantine; sp=quarantine; rua=mailto:dmarc@yourdomain.com
    
    This tells receivers to quarantine emails that fail SPF/DKIM checks, and sends you reports about delivery issues.

2. Fix Postfix main.cf Configuration Issues

Let's verify key settings in your /etc/postfix/main.cf—these are common culprits:

  • myhostname: Must be a valid FQDN (Fully Qualified Domain Name) like mail.yourdomain.com, not localhost or a generic server hostname. If it's set incorrectly, receivers will flag your emails as suspicious.
  • mydomain: Set this to your base domain (e.g., yourdomain.com), not a subdomain.
  • myorigin: Should be set to $mydomain so that your outgoing emails appear to come from yourdomain.com instead of a random server name.
  • smtpd_banner: Update it to include your FQDN to avoid generic flags:
    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    
  • TLS Settings: Enable TLS to encrypt outgoing emails—many providers mark unencrypted mail as spam:
    smtp_tls_security_level = may
    smtpd_tls_cert_file = /etc/letsencrypt/live/yourdomain.com/fullchain.pem
    smtpd_tls_key_file = /etc/letsencrypt/live/yourdomain.com/privkey.pem
    
    If you don't have an SSL cert, grab one for free with Let's Encrypt.

3. Clean Up Test Emails & Sender Info

When sending from the command line, avoid red flags:

  • Use a valid sender address like admin@yourdomain.com instead of root@localhost or user@server-1234.
  • Keep test email content simple (e.g., "Hi, this is a test email from my Ubuntu server")—avoid spammy keywords, excessive caps, or random links.

4. Test & Debug

  • Use swaks to send a test email and get detailed delivery feedback:
    sudo apt-get install swaks
    swaks --to recipient@example.com --from admin@yourdomain.com --server localhost
    
  • Check Postfix logs for errors or rejection messages:
    tail -f /var/log/mail.log
    
    Look for lines mentioning "spam", "rejected", or authentication failures.

Once you've implemented these changes, give DNS records 1-2 hours to propagate, then test again. Chances are, missing SPF/DKIM/DMARC or incorrect hostname settings are the root cause here.

内容的提问来源于stack exchange,提问作者Martin AJ

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:55:20