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

CentOS 7下使用Postfix无法发送邮件问题求助

解决Postfix通过Zoho SMTP发送邮件的SASL认证失败问题

问题场景

执行以下命令尝试发送邮件:

echo "This is the body of the email." | mailx -s "Subject of the Email" -r "Emailadmin@digiklug.com" knowyrtech@gmail.com

错误日志

执行tail -f /var/log/maillog获取的日志内容:

Oct 14 19:34:50 SGGS-Prod postfix/pickup[2065215]: 39FCB48B3BA: uid=0 from=<Emailadmin@digiklug.com>
Oct 14 19:34:50 SGGS-Prod postfix/cleanup[2065227]: 39FCB48B3BA: message-id=<652aed5a.MSgmspqvsdKAT5tU%Emailadmin@digiklug.com>
Oct 14 19:34:50 SGGS-Prod postfix/qmgr[2065216]: 39FCB48B3BA: from=<Emailadmin@digiklug.com>, size=479, nrcpt=1 (queue active)
Oct 14 19:34:51 SGGS-Prod postfix/smtp[2065218]: warning: SASL authentication failure: No worthy mechs found
Oct 14 19:34:51 SGGS-Prod postfix/smtp[2065218]: 39FCB48B3BA: to=<knowyrtech@gmail.com>, relay=smtp.zoho.com[136.143.190.56]:587, delay=1.5, delays=0/0/1.5/0, dsn=4.7.0, status=deferred (SASL authentication failed; cannot authenticate to server smtp.zoho.com[136.143.190.56]: no mechanism available)

当前配置

Postfix主配置(/etc/postfix/main.cf)

relayhost = [smtp.zoho.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_sasl_mechanism_filter = plain, login

SASL密码文件配置步骤

# 写入账号密码
echo "[smtp.zoho.com]:587    Emailadmin@digiklug.com:my-password" >> /etc/postfix/sasl_passwd
# 设置安全权限
sudo chmod 600 /etc/postfix/sasl_passwd
# 生成哈希映射文件
sudo postmap /etc/postfix/sasl_passwd

解决方案

  • 安装SASL认证依赖:日志提示"No worthy mechs found",说明系统缺少支持PLAIN/LOGIN认证机制的SASL模块,根据系统类型执行安装命令:

    # Debian/Ubuntu系统
    sudo apt-get install libsasl2-modules
    # RHEL/CentOS系统
    sudo yum install cyrus-sasl-plain
    
  • 重启Postfix服务:安装完成后重启服务加载新模块:

    sudo systemctl restart postfix
    
  • 验证账号密码有效性:如果开启了Zoho邮箱的两步验证,必须使用应用专用密码而非主密码,确保sasl_passwd中的账号和密码完全匹配。

  • 调整TLS配置(可选):若仍有问题,可尝试降低TLS安全级别,修改/etc/postfix/main.cf中的对应配置:

    smtp_tls_security_level = may
    

    修改后再次重启Postfix。

  • 重新测试发送:执行测试命令并查看日志确认结果:

    echo "Test email content" | mailx -s "Test Subject" -r "Emailadmin@digiklug.com" knowyrtech@gmail.com
    tail -f /var/log/maillog
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 07:29:52