mailrelay/README.md

100 lines
3.1 KiB
Markdown
Raw Normal View History

2018-11-29 02:24:10 +01:00
# mailrelay
2019-03-04 20:54:52 +01:00
[![Build Status](https://travis-ci.org/wiggin77/mailrelay.svg?branch=master)](https://travis-ci.org/wiggin77/mailrelay)
2018-11-29 02:24:10 +01:00
`mailrelay` is a simple mail relay that can take unauthenticated SMTP emails (e.g. over port 25) and relay them to authenticated, TLS-enabled SMTP servers. Plus it's easy to configure.
## Use case
Some older appliances such as scanners, multi-function printers, RAID cards or NAS boxes with monitoring, can only send email without any authentication or encryption over port 25. `mailrelay` can send those emails to your Gmail, Fastmail or other provider.
Run `mailrelay` on a local PC and set your device (e.g. scanner) to send mail to that PC.
`mailrelay` is written in Go, and can be compiled for any Go supported platform including Linux, MacOS, Windows.
2020-05-09 03:29:59 +02:00
## Encryption
`mailrelay` uses TLS to connect to your SMTP provider. By default implicit TLS connections are assumed, meaning the connection is established
using TLS at the socket level. This is in accordance with [RFC 8314 section 3](https://tools.ietf.org/html/rfc8314#section-3). These connections usually use port 465.
However, some providers do not adhere to this recommendation (I'm looking at you Office365!) and only support the legacy STARTTLS command, which expects a non-encrypted socket connection at first, which is then upgraded to TLS. To enable this, set `smtp_starttls` to `true` in your config.
These connections usually use port 587.
## Testing your configuration
You can send a test email using the `-test` flag. A email will be sent using the SMTP provider specified in your `mailrelay.json` configuration.
```bash
./mailrelay -config=./mailrelay.json -test -sender=dlauder@warpmail.net -rcpt=ender.wiggin@warpmail.net
```
2018-11-29 02:24:10 +01:00
## Example (Linux)
On local PC (192.168.1.54) create file `/etc/mailrelay.json` with contents:
/etc/mailrelay.json
```json
{
"smtp_server": "smtp.fastmail.com",
"smtp_port": 465,
2020-05-09 03:29:59 +02:00
"smtp_starttls": false,
2018-11-29 02:24:10 +01:00
"smtp_username": "username@fastmail.com",
"smtp_password": "secretAppPassword",
"local_listen_ip": "0.0.0.0",
2020-04-09 15:18:50 +02:00
"local_listen_port": 2525,
"allowed_hosts": ["*"]
2018-11-29 02:24:10 +01:00
}
```
Run `mailrelay`,
```Bash
./mailrelay
```
Default location for configuration file is `/etc/mailrelay.json` but can be changed via `--config` flag. For example,
```bash
mailrelay --config=/home/myname/mailrelay.json
```
Configure your scanner or other device to send SMTP mail to server `192.168.1.54:2525`. Each email will be relayed to `smtp.fastmail.com` using the credentials above, including any file attachments.
2018-11-29 02:27:01 +01:00
## Example 2 (Linux - Systemd service)
Create configuration file as above, and also create,
/etc/systemd/system/mailrelay.service
```ini
[Unit]
Description=Mail Relay Service
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/local/bin/mailrelay
[Install]
WantedBy=multi-user.target
```
Copy `mailrelay` to `/usr/local/bin/`.
Run,
```Bash
sudo systemctl start mailrelay
sudo systemctl enable mailrelay
```
Now `mailrelay` runs as a service daemon and will automatically start after reboot.
## Feedback
2020-05-08 05:50:40 +02:00
Send any questions or comments to wiggin77@warpmail.net