memiah.mail-relay

Postfix 邮件中继

设置 Postfix 通过邮件中继发送邮件,例如使用 Amazon SES。

要求

如果选择的邮件中继选项是使用 Amazon AWS SES,则为用户创建一个 IAM 用户策略“AmazonSesSendingAccess-[用户名]”,例如:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ses:SendEmail",
                "ses:SendRawEmail"
            ],
            "Resource": "*"
        }
    ]
}

角色变量

可用变量如下,包含默认值(见 defaults/main.yml):

postfix_relay_enabled: True

默认情况下,Postfix 配置是启用的,如果想关闭,请设置为 False

postfix_relay_server: ""

Postfix 中继服务器的主机名,例如“email-smtp.region.amazonaws.com”。

postfix_relay_port: 587

Postfix 中继服务器的端口。

postfix_myhostname: False

myhostname 参数指定该邮件系统的互联网主机名。默认使用从 gethostname() 获取的完全限定域名。$myhostname 是许多其他配置参数的默认值。

postfix_mydomain: False

mydomain 参数指定本地互联网域名。默认使用 $myhostname 除去第一个部分。$mydomain 是许多其他配置参数的默认值。

postfix_myorigin: False

myorigin 参数指定本地发送邮件看起来来自哪个域。默认值是附加 $myhostname,这对小网站有效。如果你的域有多台机器,应该(1)改为 $mydomain 和(2)设置一个域范围的别名数据库,将每个用户别名为 user@that.users.mailhost

为确保发件人和收件人地址之间的一致性,myorigin 还指定了附加到没有 @domain 部分的收件人地址的默认域名。

postfix_relay_recipient_canonical_maps: regexp:/etc/postfix/recipient_canonical_maps

用于信封和头部收件人地址的地址映射查找表,使用 recipient_canonical_maps。默认使用 regexp 表 类型。

postfix_relay_recipient_canonical: []
#    - pattern: "/./" (必需)
#      address: "[email protected]" (必需)

基于正则表达式表格式的规范收件人列表。

postfix_relay_recipient_canonical_classes: envelope_recipient

受到 canonical_maps 地址映射影响的地址。指定一个或多个: envelope_sender, envelope_recipient, header_sender, header_recipient

postfix_relay_catch_all_address: False
# postfix_relay_catch_all_address: [email protected]

用于重定向所有邮件的电子邮件地址。默认情况下禁用,一般只应在开发环境中启用。如果指定,这将覆盖所有 postfix_relay_recipient_canonical 项目。

postfix_relay_catch_all_pattern: /./

用于捕获所有邮件并发送到捕获地址的默认(正则表达式)模式。

postfix_virtual_alias_maps:
   - address: root
     alias: root@localhost

通过设置虚拟别名将邮件投递到本地帐户。默认情况下,任何发送给 root 的邮件将被发送到 root@localhost(本地投递)。通过将此值设置为 False 禁用所有默认别名。

postfix_relayhost_maps: []
#    - domain: "@domain.com" (必需)
#      server: "" (可选,默认为 postfix_relay_server)
#      port: 587 (可选,默认为 postfix_relay_port)
#      user: "user-here" (可选,默认为 postfix_relay_user)
#      password: "password-here" (可选,默认为 postfix_relay_password)

启用 smtp_sender_dependent_authentication,允许通过多个主机中继邮件,使用不同的凭据,具体取决于发件人的电子邮件地址。注意,域值可以指定为完整地址 [email protected] 或使用通配符 @domain.com。(见 Postfix relayhost_map 文档。)

postfix_relay_user: ""

设置 Postfix 中继用户。

postfix_relay_password: ""

设置中继服务器密码。

postfix_relay_secret_key: "secret-key-here"

从指定的 AWS 秘密密钥生成中继密码。或者,通过使用包含的脚本,将现有的 AWS 秘密密钥转换为 Amazon SES SMTP 密码,手动设置 postfix_relay_password 值:

./scripts/aws-ses-smtp-password.sh secret-key-here

依赖关系

无。

示例剧本

包含一个如何使用角色的示例(例如,通过参数传递变量)对于用户来说总是很好的:

- hosts: servers
  become: yes
  vars_files:
    - vars/main.yml
  roles:
    - memiah.mail-relay

vars/main.yml

postfix_relay_user: "user_here"
postfix_relay_password: "password_here"
postfix_relay_server: "email-smtp.region.amazonaws.com"

许可证

MIT / BSD

作者信息

此角色由 Memiah Limited 在 2016 年创建。

关于项目

Configure postfix SMTP relay.

安装
ansible-galaxy install memiah.mail-relay
许可证
Unknown
下载
457
拥有者