m0ntyG / ansible-msmtp-setup

Ansible role for msmtp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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: example@gmail.com
        user: example@gmail.com
        password: "app-password"
      - account: icloud
        host: smtp.mail.me.com
        port: 587
        auth: "on"
        from: example@icloud.com
        user: example@icloud.com
        password: "icloud-password"
    aliases:
      - user: root
        mail: root@gmail.com
      - user: cron
        mail: cron@gmail.com
      - user: www-data
        mail: apache@gmail.com

License

BSD

Author Information

Martin Schmid, mscbiz@akaritech.com

About

Ansible role for msmtp


Languages

Language:Python 65.7%Language:HTML 34.3%