ansible-msmtp-mailer/README.md

94 lines
2.5 KiB
Markdown
Raw Normal View History

2018-05-07 08:17:01 +00:00
[![Build Status](https://travis-ci.org/chriswayg/ansible-msmtp.svg?branch=master)](https://travis-ci.org/chriswayg/ansible-msmtp)
2018-04-28 18:36:01 +00:00
# Readme
2014-03-21 19:16:55 +00:00
This ansible role deploys msmtp for Debian 9 stretch (tested on vagrant)
2014-03-21 19:16:55 +00:00
2018-04-28 18:36:01 +00:00
## Prerequisite
* Having ansible installed on your workstation.
* Having an SMTP server
2014-03-21 19:16:55 +00:00
2018-04-28 18:36:01 +00:00
## How to install
2014-03-21 19:16:55 +00:00
* Use github to clone/fork in your role directory
* ansible galaxy ```ansible-galaxy install adham.helal.msmtp```
2018-04-28 18:36:01 +00:00
## 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
2014-03-21 19:16:55 +00:00
```
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
2014-03-21 19:16:55 +00:00
```msmtp_default_account: "gmail"```
- *msmtp_from:* From field
```msmtp_from : "No Reply"```
- Logging
2014-03-21 19:16:55 +00:00
- Option A (syslog)
2014-03-21 19:16:55 +00:00
```
msmtp_log : "syslog"
```
- Option B (file logging)
2014-03-21 19:16:55 +00:00
```
msmtp_log : "file"
msmtp_logfile : /var/log/msmtp.log
```
- Option C (No logging)
```
msmtp_log : "no"
```
2014-03-21 19:36:47 +00:00
- Mail aliases
- *msmtp_alias_default:* default email this required
2014-03-21 19:16:55 +00:00
```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```
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
2014-03-21 19:16:55 +00:00
**By default the mstmp will fail because the configuration uses a bogus smtp server you need to use a valid smtp server**
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-04-28 18:36:01 +00:00
## Possible issues
From field requires more work
[http://msmtp.sourceforge.net/doc/msmtp.html#Envelope_002dfrom-address](http://msmtp.sourceforge.net/doc/msmtp.html#Envelope_002dfrom-address)