Find a file
2018-05-07 16:31:19 +08:00
defaults Option not to send test mail 2018-05-07 16:30:03 +08:00
handlers Add option not to send test mail 2018-05-07 16:30:52 +08:00
meta Debian version 2018-04-29 02:21:08 +08:00
tasks Edit comments 2018-05-07 16:31:19 +08:00
templates Edit comments 2018-05-07 16:31:19 +08:00
tests Edit comments 2018-05-07 16:31:19 +08:00
vars First commit 2014-03-21 20:16:55 +01:00
.gitignore Update gitignore 2018-05-07 16:28:48 +08:00
.travis.yml Test using docker in travis 2018-05-07 16:29:25 +08:00
.travis.yml.old Test using docker in travis 2018-05-07 16:29:25 +08:00
LICENSE First commit 2014-03-21 20:16:55 +01:00
README.md Update README.md 2018-04-29 02:36:01 +08:00
Vagrantfile Debian version 2018-04-29 02:21:08 +08:00

Build Status

Readme

This ansible role deploys msmtp for Debian 9 stretch (tested on vagrant)

Prerequisite

  • Having ansible installed on your workstation.
  • Having an SMTP server

How to install

  • Use github to clone/fork in your role directory
  • ansible galaxy ansible-galaxy install adham.helal.msmtp

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 account

    msmtp_accounts:
    - account  : "gmail"
      host     : "smtp.gmail.com"
      port     : 587
      auth     : "on"
      user     : "example@gmail.example"
      password : "some password"
    - account  : "mysmtp"
      host     : "smtp.example"
      port     : 587
      auth     : "on"
      user     : "myuser"
      password : "123456"
    
  • msmtp_default_account: Default smtp account to use

    msmtp_default_account: "gmail"

  • msmtp_from: From field

    msmtp_from : "No Reply"

  • 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. (recommended)
  • Editing var/main.yml
  • Run ansible-playbook with -e
  • Edit the default/main.yml (not recommended)

Run

By default the mstmp will fail because the configuration uses a bogus smtp server you need to use a valid smtp server

ansible-playbook -l hostname msmtp.yml

Test

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

Possible issues

From field requires more work http://msmtp.sourceforge.net/doc/msmtp.html#Envelope_002dfrom-address