支持的词典类型:smtp.gmail.com

支持的词典类型:smtp.gmail.com

我正在尝试postfix在 Docker 容器内进行设置。启动时,我运行以下设置脚本:

# Install postfix/mailutils with configuration options
echo "postfix postfix/mailname string $MAILSERVER:587" | debconf-set-selections
echo "postfix postfix/main_mailer_type string 'Internet Site'" | debconf-set-selections
apt-get install -yqq postfix
apt-get install -yqq mailutils

# Setup credentials for SMTP server
mkdir -p /etc/postfix/sasl
touch /etc/postfix/sasl/sasl_passwd /etc/postfix/main.cf
echo "[$MAILSERVER]:587 $EMAIL_USER:$EMAIL_PASSWORD" >> /etc/postfix/sasl/sasl_passwd
chown -R postfix:postfix /etc/postfix
chmod 600 /etc/postfix/sasl/sasl_passwd
postmap /etc/postfix/sasl/sasl_passwd

# Create postfix configuration 
echo "relayhost = [$MAILSERVER]:587" >> /etc/postfix/main.cf
echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf
echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd" >> /etc/postfix/main.cf
echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf
echo "smtp_use_tls = yes" >> /etc/postfix/main.cf
echo "debug_peer_list = $MAILSERVER" >> /etc/postfix/main.cf
echo "debug_peer_level = 3" >> /etc/postfix/main.cf
echo "smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt" >> /etc/postfix/main.cf

# Reload postfix for new configurations to take effect
postfix reload
/etc/init.d/postfix restart

运行脚本后,我的脚本末尾出现以下内容/etc/postfix/main.cf

# Use gmail
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
debug_peer_list=smtp.gmail.com
debug_peer_level=3
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt

我已经确认/etc/postfix/sasl_passwd并且/etc/ssl/certs/ca-certificates.crt存在,但是我不断收到:

postfix/bounce[1052]: error: unsupported dictionary type: smtp.gmail.com

注意:我见过类似标题的问题,但发布的解决方案对我的设置没有帮助。

答案1

smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

在这里,您使用 Berkeley DB 作为Postfix 查找表类型

hash

基于哈希的索引文件类型。这仅在支持 Berkeley DB 数据库的系统上可用。公共数据库文件使用postmap(1)postalias(1)命令创建,私有数据库由 Postfix 守护进程维护。使用的数据库名称hash:table是不带后缀的数据库文件名.db

因此, 的存在/etc/postfix/sasl_passwd并不像/etc/postfix/sasl_passwd.db生成的的存在那么重要postmap /etc/postfix/sasl_passwd。但是,如果您缺少该文件,我相信您应该会收到一条错误信息,直接告知您。

您的 Postfix 可能缺少 Berkeley DB 支持。在 Debian 上,默认postfix软件包内置了该支持,您可以使用 检查它是否具有该支持postconf -m。如果列表不包含hashbtree,则您缺少该支持。然后,有关更多信息,请参阅Postfix Berkeley DB 操作方法

答案2

我解决了这个问题,但我不确定这个问题的根本原因是什么。

mydestination在安装过程中,gmail SMTP 服务器被添加到中的值main.cf

我最终运行了以下脚本来Dockerfile修复该值:

sed -i '/mydestination =/d' /etc/postfix/main.cf
echo "mydestination = localhost.localdomain, localhost" >> /etc/postfix/main.cf

相关内容