Go to file
CASSONNET Guillaume 6a87854b47 fix selinux is only for RHEL 9.3 2023-11-24 18:48:57 +01:00
defaults bump msmtp-1.8.25-1 + fix selinux for RHEL 8.9/9.3 2023-11-24 18:34:32 +01:00
files Remove msmtp-1.8.19-1 files 2022-07-31 11:15:55 +02:00
handlers fix handler 2021-07-12 21:51:38 +02:00
meta Molecule fix 2022-02-20 13:49:00 +01:00
molecule/default Fix molecule 2023-03-06 21:51:17 +01:00
tasks fix selinux is only for RHEL 9.3 2023-11-24 18:48:57 +01:00
templates Templatize more variables 2023-08-20 09:21:28 +02:00
tests Enable test mail by default; disable on travis 2018-05-08 20:18:28 +08:00
vars yamllint + ansible-lint 2021-07-01 20:52:55 +02:00
.ansible-lint Fix molecule - hopefully 2022-02-20 13:30:06 +01:00
.gitignore bump msmtp-1.8.23-1 2023-02-14 22:33:20 +01:00
LICENSE Update meta and readme 2018-05-07 22:28:10 +08:00
README.md Fix doc 2022-08-08 22:31:23 +02:00
docker_rebuild_msmtp_rpm.sh Fix build, move to fc37 2023-04-09 10:39:38 +02:00

README.md

Build Status

ansible-msmtp-mailer

This ansible role deploys msmtp as a mailer for RHEL8 and compatible.

Prerequisite

  • Access to a functioning SMTP server.

How to install

  • Either use git to clone/download into your roles directory:
    • git clone https://git.garbaye.fr/Garbaye/ansible-msmtp-mailer.git
  • Or import in your requirements.yml:
    roles:
      - src: git+https://git.garbaye.fr/Garbaye/ansible-msmtp-mailer.git
    

Variables

All the default variables are located defaults/main.yml. Mostly you would need to configure the following variables.

  • msmtp_accounts: You can define one or more smtp accounts:

    msmtp_accounts:
    - account:   gmail
      host:      smtp.gmail.com
      port:      587
      auth:      "on"
      from:      example@gmail.example
      user:      example@gmail.example
      password:  "some password"
    - account:   mysmtp
      host:      smtp.example
      port:      587
      auth:      "on"
      from:      admin@example.org
      user:      myuser@example.org
      password:  plain-text-password2
    
  • msmtp_default_account: Default smtp account to use

    msmtp_default_account: "gmail"

  • Logging

    • Option A (syslog)

       msmtp_log : "syslog"
      
    • Option B (file logging)

       msmtp_log     : "file"
       msmtp_logfile : /var/log/msmtp.log
      
    • Option C (No logging)

       msmtp_log     : "no"
      
  • Mail aliases

    • msmtp_alias_default: default email this required

      msmtp_alias_default : ops@example.com

    • msmtp_alias_root: root email this is optional

      msmtp_alias_root : root@example.com

    • msmtp_alias_cron: cron email this optional

      msmtp_alias_cron : cron@example.com

Configure

You can configure your variables in ansible with one of the following

  • Create a variable in host/group variables directory.
  • Editing vars/main.yml
  • Run ansible-playbook with -e
  • Edit the defaults/main.yml (not recommended)

Example Playbook

---
- hosts: all
  roles:
    - ansible-msmtp-mailer

Run

  • mstmp used to function out of the box with the provided defaults/main.yml settings, because the configuration used a real smtp server for testing, but Yandex does not allow this any more. Instead use a Gmail account for testing.

    ansible-playbook -l hostname msmtp.yml

Test

You should get a test mail if it works as expected on the root mail

Documentation

msmtp manual

Authors:

License:

  • Apache 2.0