memiah.mail-relay

Postfix Mail Relay

This guide explains how to configure Postfix to send emails through a mail relay, like Amazon SES.

Requirements

If you want to use Amazon AWS SES as your mail relay, create a policy named "AmazonSesSendingAccess-[username]" for your IAM user. The policy should look like this:

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

Role Variables

Here are the available settings you can adjust, along with their default values (found in defaults/main.yml):

  • postfix_relay_enabled: True

    • This turns on Postfix's mail relay by default. Set it to False to disable it.
  • postfix_relay_server: ""

    • The hostname for the Postfix relay server, e.g., "email-smtp.region.amazonaws.com".
  • postfix_relay_port: 587

    • The port number for the Postfix relay server.
  • postfix_myhostname: False

    • This sets the internet hostname for your mail system. By default, it uses the full domain name from the system.
  • postfix_mydomain: False

    • This sets your local internet domain name. The default is to take the hostname and remove the first part.
  • postfix_myorigin: False

    • This defines the domain that outgoing mail appears to come from. Usually, it adds the hostname. For multiple machines under one domain, change this to $mydomain.
  • postfix_relay_recipient_canonical_maps: regexp:/etc/postfix/recipient_canonical_maps

    • This is a table for mapping recipient addresses in envelopes and headers. It uses a regex format by default.
  • postfix_relay_recipient_canonical: []

    • A list of address mappings based on regex patterns.
  • postfix_relay_recipient_canonical_classes: envelope_recipient

    • Specifies what types of addresses the mapping applies to (e.g., envelope_sender, etc.).
  • postfix_relay_catch_all_address: False

    • An email address to redirect all emails. This is off by default and usually only for development.
  • postfix_relay_catch_all_pattern: /./

    • The regex pattern used to redirect all emails to the catch-all address.
  • postfix_virtual_alias_maps:

      • address: root alias: root@localhost
    • This sets up virtual aliases for local accounts. By default, mail to root goes to root@localhost. Disable this by setting to False.
  • postfix_relayhost_maps: []

    • This allows using different SMTP servers for different sender emails, with optional credentials.
  • postfix_relay_user: ""

    • The username for the Postfix relay server.
  • postfix_relay_password: ""

    • The password for the relay server.
  • postfix_relay_secret_key: "secret-key-here"

    • Use this secret key to generate the relay password. Alternatively, use the bash script:
./scripts/aws-ses-smtp-password.sh secret-key-here

Dependencies

None.

Example Playbook

Here’s an example of how to utilize this role. It demonstrates how to set variables in a playbook:

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

Inside vars/main.yml:

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

License

MIT / BSD

Author Information

This role was created in 2016 by Memiah Limited.

Informazioni sul progetto

Configure postfix SMTP relay.

Installa
ansible-galaxy install memiah.mail-relay
Licenza
Unknown
Download
457
Proprietario