2018-05-07 15:21:39 +00:00
|
|
|
[![Build Status](https://travis-ci.org/chriswayg/ansible-msmtp-mailer.svg?branch=master)](https://travis-ci.org/chriswayg/ansible-msmtp-mailer)
|
2018-04-28 18:36:01 +00:00
|
|
|
|
2018-05-07 14:28:10 +00:00
|
|
|
# chriswayg.msmtp-mailer
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-05-26 14:19:18 +00:00
|
|
|
This ansible role deploys msmtp as a mailer for Debian, Ubuntu, Arch & Alpine Linux
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-04-28 18:36:01 +00:00
|
|
|
## Prerequisite
|
2018-05-07 14:38:25 +00:00
|
|
|
* Access to a functioning SMTP server.
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-04-28 18:36:01 +00:00
|
|
|
## How to install
|
2018-05-07 14:28:10 +00:00
|
|
|
* Use github to clone/fork into your role directory
|
|
|
|
* ansible galaxy ```ansible-galaxy install chriswayg.msmtp-mailer```
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-04-28 18:36:01 +00:00
|
|
|
## Variables
|
2018-04-28 18:21:08 +00:00
|
|
|
All the default variables are located **defaults/main.yml**. Mostly you would need to configure the following variables.
|
2018-05-07 14:28:10 +00:00
|
|
|
- *msmtp_accounts:* You can define one or more smtp accounts:
|
2018-04-28 18:21:08 +00:00
|
|
|
|
2014-03-21 19:16:55 +00:00
|
|
|
```
|
|
|
|
msmtp_accounts:
|
2018-05-07 14:28:10 +00:00
|
|
|
- account : gmail
|
|
|
|
host : smtp.gmail.com
|
2014-03-21 19:16:55 +00:00
|
|
|
port : 587
|
|
|
|
auth : "on"
|
2018-05-07 14:28:10 +00:00
|
|
|
from : example@gmail.example
|
|
|
|
user : example@gmail.example
|
2014-03-21 19:16:55 +00:00
|
|
|
password : "some password"
|
2018-05-07 14:28:10 +00:00
|
|
|
- account : mysmtp
|
|
|
|
host : smtp.example
|
2014-03-21 19:16:55 +00:00
|
|
|
port : 587
|
|
|
|
auth : "on"
|
2018-05-07 14:28:10 +00:00
|
|
|
from : admin@example.org
|
|
|
|
user : myuser@example.org
|
|
|
|
password : plain-text-password2
|
2014-03-21 19:16:55 +00:00
|
|
|
```
|
2018-04-28 18:21:08 +00:00
|
|
|
- *msmtp_default_account:* Default smtp account to use
|
2014-03-21 19:16:55 +00:00
|
|
|
|
|
|
|
```msmtp_default_account: "gmail"```
|
|
|
|
|
2018-04-28 18:21:08 +00:00
|
|
|
- Logging
|
2014-03-21 19:16:55 +00:00
|
|
|
- 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"
|
|
|
|
```
|
2014-03-21 19:36:47 +00:00
|
|
|
|
2018-04-28 18:21:08 +00:00
|
|
|
- Mail aliases
|
|
|
|
- *msmtp_alias_default:* default email this required
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-05-07 14:38:25 +00:00
|
|
|
`msmtp_alias_default : ops@example.com`
|
2014-03-21 19:16:55 +00:00
|
|
|
|
|
|
|
- *msmtp_alias_root:* root email this is optional
|
|
|
|
|
2018-05-07 14:38:25 +00:00
|
|
|
`msmtp_alias_root : root@example.com`
|
2014-03-21 19:16:55 +00:00
|
|
|
|
|
|
|
- *msmtp_alias_cron:* cron email this optional
|
|
|
|
|
2018-05-07 14:38:25 +00:00
|
|
|
`msmtp_alias_cron : cron@example.com`
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-04-28 18:36:01 +00:00
|
|
|
## Configure
|
2014-03-21 19:16:55 +00:00
|
|
|
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)
|
|
|
|
|
2018-04-28 18:36:01 +00:00
|
|
|
## Run
|
2018-05-07 14:28:10 +00:00
|
|
|
**By default mstmp will work as the configuration uses a real smtp server (for testing only!)**
|
2018-04-28 18:21:08 +00:00
|
|
|
|
2014-03-21 19:23:28 +00:00
|
|
|
```ansible-playbook -l hostname msmtp.yml```
|
2014-03-21 19:16:55 +00:00
|
|
|
|
2018-04-28 18:36:01 +00:00
|
|
|
## Test
|
2014-03-21 19:16:55 +00:00
|
|
|
You should get a test mail if it works on the root mail
|
|
|
|
|
2018-05-07 14:28:10 +00:00
|
|
|
## Documentation
|
|
|
|
[msmtp manual](http://msmtp.sourceforge.net/doc/msmtp.html)
|