Oefenweb.postfix
postfix
在类Debian系统上设置Postfix服务器。
需求
无
变量
postfix_install
[默认值:[postfix, mailutils, libsasl2-2, sasl2-bin, libsasl2-modules]
]: 要安装的软件包postfix_hostname
[默认值:{{ ansible_fqdn }}
]: 主机名,用于myhostname
和mydestination
postfix_mailname
[默认值:{{ ansible_fqdn }}
]: 邮件名称(在/etc/mailname
中),用于myorigin
postfix_compatibility_level
[可选]: 启用向后兼容性时,Postfix 会查找未显式设置的默认值,并在需要向后兼容的默认设置时记录消息(例如2
,Postfix >= 3.0
)postfix_default_database_type
[默认值:hash
]: 用于newaliases
、postalias
和postmap
命令的默认数据库类型postfix_aliases
[默认值:[]
]: 确保存在于/etc/aliases
中的别名postfix_aliases_database_type
[默认值:"{{ postfix_default_database_type }}"
]: 别名的数据库类型postfix_virtual_aliases
[默认值:[]
]: 确保存在于/etc/postfix/virtual
中的虚拟别名postfix_sender_canonical_maps
[默认值:[]
]:/etc/postfix/sender_canonical_maps
中的发件人地址重写postfix_sender_canonical_maps_database_type
[默认值:"{{ postfix_default_database_type }}"
]: 用于postfix_sender_canonical_maps
的数据库类型postfix_recipient_canonical_maps
[默认值:[]
]:/etc/postfix/recipient_canonical_maps
中的收件人地址重写postfix_recipient_canonical_maps_database_type
[默认值:"{{ postfix_default_database_type }}"
]: 用于postfix_recipient_canonical_maps
的数据库类型postfix_transport_maps
[默认值:[]
]: 基于收件人地址的邮件传递映射/etc/postfix/transport_maps
postfix_transport_maps_database_type
[默认值:"{{ postfix_default_database_type }}"
]: 用于postfix_transport_maps
的数据库类型postfix_sender_dependent_relayhost_maps
[默认值:[]
]: 基于发件人地址的传输映射/etc/postfix/sender_dependent_relayhost_maps
postfix_header_checks
[默认值:[]
]: 用于主要非MIME消息头内容检查的查找表/etc/postfix/header_checks
postfix_header_checks_database_type
[默认值:regexp
]: 用于header_checks
的数据库类型postfix_generic
[默认值:postfix_smtp_generic_maps
]: 已弃用,使用postfix_smtp_generic_maps
postfix_smtp_generic_maps
[默认值:[]
]:/etc/postfix/generic
中的通用地址映射postfix_smtp_generic_maps_database_type
[默认值:"{{ postfix_default_database_type }}"
]: 用于smtp_generic_maps
的数据库类型postfix_mydestination
[默认值:["{{ postfix_hostname }}", 'localdomain', 'localhost', 'localhost.localdomain']
]: 指定此机器将本地投递的域,而不是转发至另一台机器postfix_mynetworks
[默认值:['127.0.0.0/8', '[::ffff:127.0.0.0]/104', '[::1]/128']
]: "可信"远程SMTP客户端的列表,具有比“陌生人”更高的特权postfix_inet_interfaces
[默认值:all
]: 绑定的网络接口postfix_inet_protocols
[默认值:all
]: Postfix 在建立或接受连接时尝试使用的互联网协议postfix_smtp_ipv4_bind
[可选]: 要使用的出站网络接口(IPv4)postfix_smtp_ipv6_bind
[可选]: 要使用的出站网络接口(IPv6)postfix_relayhost
[默认值:''
(无中继主机)]: 中继所有邮件的主机名postfix_relayhost_mxlookup
[默认值:false
(不使用MX查找)]: 查找MX记录而不是A记录用于中继主机postfix_relayhost_port
[默认值: 587]: 中继端口(在设置的postfix_relayhost
上)postfix_relaytls
[默认值:false
]: 发送邮件时使用TLS与中继主机连接postfix_smtpd_client_restrictions
[可选]: 客户端限制列表postfix_smtpd_helo_restrictions
[可选]: helo限制列表postfix_smtpd_sender_restrictions
[可选]: 发件人限制列表postfix_smtpd_recipient_restrictions
[可选]: 收件人限制列表postfix_smtpd_relay_restrictions
[可选]: 邮件中继控制的访问限制列表postfix_smtpd_data_restrictions
[可选]: 数据限制列表postfix_sasl_auth_enable
[默认值:true
]: 在SMTP客户端中启用SASL认证postfix_sasl_user
[默认值:postmaster@{{ ansible_domain }}
]: SASL中继用户名postfix_sasl_password
[默认值:k8+haga4@#pR
]: SASL中继密码 务必更改这个密码!postfix_sasl_security_options
[默认值:noanonymous
]: SMTP客户端SASL安全选项postfix_sasl_tls_security_option
[默认值:noanonymous
]: SMTP客户端SASL TLS安全选项postfix_sasl_mechanism_filter
[默认值:''
]: SMTP客户端SASL认证机制过滤器postfix_smtp_tls_security_level
[默认值:encrypt
]: Postfix SMTP客户端的默认SMTP TLS安全级别postfix_smtp_tls_wrappermode
[默认值:false
]: 请求Postfix SMTP客户端使用传统的SMTPS协议连接,不使用STARTTLS命令postfix_smtp_tls_note_starttls_offer
[默认值:true
]: 记录提供STARTTLS的远程SMTP服务器的主机名,当该服务器未启用TLS时postfix_smtp_tls_cafile
[可选]: 包含受信任的根CA以签署远程SMTP服务器证书或中间CA证书的CA证书文件(例如/etc/ssl/certs/ca-certificates.crt
)postfix_smtpd_banner
[默认值:$myhostname ESMTP $mail_name (Ubuntu)
]: 问候横幅 您必须在文本开头指定 $myhostname 。这符合SMTP协议要求。postfix_disable_vrfy_command
[默认值:true
]: 禁用SMTP VRFY
命令。这样可以阻止一些获取电子邮件地址的技术postfix_message_size_limit
[默认值:10240000
]: 消息的最大大小(字节),包括信封信息postfix_smtpd_tls_cert_file
[默认值:/etc/ssl/certs/ssl-cert-snakeoil.pem
]: 证书文件的路径postfix_smtpd_tls_key_file
[默认值:/etc/ssl/certs/ssl-cert-snakeoil.key
]: 密钥文件的路径postfix_smtpd_security_level
[可选]: Postfix SMTP服务器的SMTP TLS安全级别postfix_smtp_tls_mandatory_ciphers
[可选]: Postfix SMTP客户端使用的强制TLS最低加密等级postfix_smtp_tls_mandatory_protocols
[可选]: Postfix SMTP客户端使用的强制TLS加密TLS协议postfix_smtp_tls_protocols
[可选]: Postfix SMTP客户端使用的机会TLS加密TLS协议postfix_smtpd_tls_mandatory_ciphers
[可选]: Postfix SMTP服务器使用的强制TLS最低加密等级postfix_smtpd_tls_mandatory_protocols
[可选]: Postfix SMTP服务器接受的强制TLS加密的TLS协议postfix_smtpd_tls_protocols
[可选]: Postfix SMTP服务器接受的机会TLS加密的TLS协议postfix_raw_options
[默认值:[]
]: 额外(不支持的)配置项的列表
依赖
debconf
debconf-utils
示例
一个简单的示例,不使用SASL中继:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases:
- user: root
alias: [email protected]
一个简单的示例,具有虚拟别名以进行邮件转发,不使用SASL中继:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_mydestination:
- "{{ postfix_hostname }}"
- '$mydomain'
- localdomain
- localhost
- localhost.localdomain
postfix_virtual_aliases:
- virtual: [email protected]
alias: [email protected]
- virtual: [email protected]
alias: [email protected], [email protected]
一个简单的示例,重写发件人地址:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_sender_canonical_maps:
- sender: root
rewrite: [email protected]
如果要启用中继,请提供中继主机名称:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases:
- user: root
alias: [email protected]
postfix_relayhost: mail.yourdomain.org
提供中继域名并使用MX记录,如果您想启用对域的DNS MX记录的中继:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases:
- user: root
alias: [email protected]
postfix_relayhost: yourdomain.org
postfix_relayhost_mxlookup: true
条件中继:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_transport_maps:
- pattern: '[email protected]'
result: ':'
- pattern: '*'
result: "smtp:{{ ansible_lo['ipv4']['address'] }}:1025"
postfix_sender_dependent_relayhost_maps:
- pattern: '[email protected]'
result: 'DUNNO'
- pattern: '[email protected]'
result: 'DUNNO'
- pattern: '*'
result: "smtp:{{ ansible_lo['ipv4']['address'] }}:1025"
使用正则表达式表的别名(将所有本地邮件转发到指定地址):
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases_database_type: regexp
postfix_aliases:
- user: /.*/
alias: [email protected]
用于AWS SES支持:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases:
- user: root
alias: [email protected]
postfix_relayhost: email-smtp.us-east-1.amazonaws.com
postfix_relaytls: true
# AWS IAM SES凭证(非访问密钥):
postfix_sasl_user: AKIXXXXXXXXXXXXXXXXX
postfix_sasl_password: ASDFXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
用于MailHog支持:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases:
- user: root
alias: [email protected]
postfix_relayhost: "{{ ansible_lo['ipv4']['address'] }}"
postfix_relayhost_port: 1025
postfix_sasl_auth_enable: false
用于Gmail支持:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_aliases:
- user: root
alias: [email protected]
postfix_relayhost: smtp.gmail.com
postfix_relaytls: true
postfix_smtp_tls_cafile: /etc/ssl/certs/ca-certificates.crt
postfix_sasl_user: 'foo'
postfix_sasl_password: 'bar'
如果您为Google账户配置了额外的安全性以使用双重验证,则
postfix将无法再发送电子邮件,您可能会在 /var/log/mail.log
文件中看到错误信息。
要解决此问题,您需要访问您Google账户设置中的 (授权应用程序和站点) 页面。在此页面中输入要授权的应用名称(Postfix),然后单击生成按钮。
将 postfix_sasl_password
变量设置为该页面生成的密码。
一个简单的示例,演示如何添加一些原始配置:
---
- hosts: all
roles:
- oefenweb.postfix
vars:
postfix_raw_options:
- |
milter_default_action = accept
milter_protocol = 6
smtpd_milters = unix:opendkim/opendkim.sock unix:opendmarc/opendmarc.sock unix:spamass/spamass.sock unix:clamav/clamav-milter.ctl
milter_connect_macros = "i j {daemon_name} v {if_name} _"
policyd-spf_time_limit = 3600
许可证
MIT
作者信息
Mischa ter Smitten
反馈、错误报告、请求等
欢迎 反馈!