ansible_msmtp_setup

msmtp-setup

Ansible role to install and configure msmtp on Debian, CentOS, Ubuntu, Alpine and Archlinux.

Requirements

None

Role Variables

KeyValue
msmtp_global_tls_trustfile location of ca-certificates
msmtp_global_auth enable authentification for all accounts
msmtp_global_tls enable tls for all accounts
msmtp_global_starttls enable startls for all accounts
msmtp_global_log This can be either set to syslog (default) or to file
msmtp_global_logfile If logging is set to file mode, set here the location of the outputfile
msmtp_domain Set the argument of the SMTP EHLO (or LMTP LHLO) command
msmtp_default_account If no other account is specified, set the default account to be used
msmtp_alias_default Set the default account to be used with nonmapped usernames (see aliases)
msmtp_aliases The location of the aliases file (typically /etc/aliases)

Account Settings

Multiple Accounts can be configured under the accounts key (see example)

KeyValue
msmtp_account.account Sets the name of the account
msmtp_account.host Sets the name of the smtp server to be used
msmtp_account.port Sets the port of the smtp server to be used
msmtp_account.auth Enables ("on) or disables ("off") authentication. Be aware that the value should be quoted
msmtp_account.from Sets the sender e-mail address
msmtp_account.user Sets the username for the smtp server
msmtp_account.user Sets the password for the smtp server

Alias Settings

The aliases file maps Linux accounts to e-mail addresses. These mappings can be specified under the aliases key (see example)

KeyValue
user Sets the Linux username (e.g. root)
mail Sets the mail account to be used with that username

Dependencies

None

Example Playbook

Below is an example playbook. Do note that due to increased default security for gmail, you will need to create an application password for usage with msmtp and also allow less secure apps.

It should be noted that gmail and icloud can change their policies at any time, so this is not guaranteed to work indefinitely.

- hosts: localhost
  remote_user: root
  roles:
    - fauch922.ansible_msmtp_setup
  vars:
    msmtp_global_tls_trustfile:
    msmtp_global_auth: "on"
    msmtp_global_tls: "on"
    msmtp_global_starttls: "on"
    msmtp_global_log: syslog
    msmtp_domain: localhost
    msmtp_default_account: gmail
    accounts:
      - account: gmail
        host: smtp.gmail.com
        port: 587
        auth: "on"
        from: [email protected]
        user: [email protected]
        password: "app-password"
      - account: icloud
        host: smtp.mail.me.com
        port: 587
        auth: "on"
        from: [email protected]
        user: [email protected]
        password: "icloud-password"
    aliases:
      - user: root
        mail: [email protected]
      - user: cron
        mail: [email protected]
      - user: www-data
        mail: [email protected]

License

BSD

Author Information

Martin Schmid, [email protected]

About

installs and configures msmtp on Debian, Centos, Alpine and Arch Linux

Install
ansible-galaxy install Fauch922/ansible-msmtp-setup
GitHub repository
License
Unknown
Downloads
34
Owner