2018-05-07 23:21:39 +08:00

2.3 KiB

Build Status


This ansible role deploys msmtp as a mailer for Debian / Ubuntu.


  • Access to a functioning SMTP server.

How to install

  • Use github to clone/fork into your role directory
  • ansible galaxy ansible-galaxy install chriswayg.msmtp-mailer


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:

    - account  : gmail
      host     :
      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     :
      user     :
      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 :

    • msmtp_alias_root: root email this is optional

      msmtp_alias_root :

    • msmtp_alias_cron: cron email this optional

      msmtp_alias_cron :


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

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


By default mstmp will work as the configuration uses a real smtp server (for testing only!)

ansible-playbook -l hostname msmtp.yml


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


msmtp manual