I'm trying to setup postfix
inside a Docker container. On startup I'm running the following setup script:
# 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
After running the script I end up with the following at the end of my /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
I have confirmed that /etc/postfix/sasl_passwd
and /etc/ssl/certs/ca-certificates.crt
exist but I keep getting:
postfix/bounce[1052]: error: unsupported dictionary type: smtp.gmail.com
Note: I have seen questions with similar titles but the solutions posted haven't helped with my setup.
Я решил эту проблему, но не уверен, что ее изначально вызвало.
В процессе установки SMTP-сервер Gmail был добавлен к значению mydestination
в main.cf
.
В итоге я запустил следующий скрипт в моем Dockerfile
, чтобы зафиксировать значение:
sed -i '/mydestination =/d' /etc/postfix/main.cf
echo "mydestination = localhost.localdomain, localhost" >> /etc/postfix/main.cf
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
Вот, пожалуйста использование Berkeley DB в качестве таблицы поиска Postfix типа :
hash
Индексированный тип файла, основанный на хешировании. Это доступно только на системы с поддержкой баз данных Berkeley DB. Файлы общедоступной базы данных создаются с помощью команды
postmap (1)
илиpostalias (1)
, а частные базы данных поддерживаются демонами Postfix. Используемое имя базы данных вхэш: таблица
- это имя файла базы данных без суффикса.db
.
Следовательно, существование / etc / postfix / sasl_passwd
не так актуально, поскольку существует /etc/postfix/sasl_passwd.db
, созданный с помощью postmap / etc / postfix / sasl_passwd
. Однако, если вы пропустили этот файл, я считаю, что вместо этого у вас должна быть ошибка, сообщающая об этом напрямую.
Возможно, в вашем Postfix отсутствует поддержка Berkeley DB. В Debian пакет постфикса по умолчанию
построен с поддержкой, и вы можете проверить, есть ли он, используя postconf -m
. Если в списке нет хэша
и btree
, вам не хватает поддержки. Затем для получения дополнительной информации обратитесь к Postfix Berkeley DB Howto .