Open coolaj86 opened 8 months ago
This is great, thanks!
Also, if you want to test SMTP directly, swaks is a great tool for this, comes in most distro repositories I believe.
When using startls (port 587 etc), you need to add --tls
:
swaks --to youremail@example.com --from youremail@example.com --port 587 --tls
When testing user authentication:
swaks --to youremail@example.com --from youremail@example.com --auth-user yourusername --auth-password yourpassword --port 587 --tls
When testing a specific IP/interface, add --server 127.0.0.1
, where 127.0.0.1
is the IP.
@coolaj86 How are you shipping logs? This is the first time i've used serviceman and journalctl -xef --unit smtprelay.service
is showing great output but strangely /var/log/smtprelay
is an empty folder.
If it works with systemd you could just use StandardOutput/Standard error in your service file to log to file.
Depending what you mean by shipping logs but depending what you're trying to do it might be easier to hook into joirnalctl vs writing to file.
Thanks! Here's what I did if it helps other people:
sudo vi /etc/systemd/system/smtprelay.service
[Service]
StandardOutput=append:/var/log/smtprelay/service.log
StandardError=append:/var/log/smtprelay/service_error.log
touch /var/log/smtprelay/service.log
touch /var/log/smtprelay/service_error.log
sudo systemctl reload smtprelay.service
Then added /var/log/smtprelay/*.log as a folder to look for in my collector configuration and it started picking it up
I just set this up for a client. This is the config we ended up going with.
Directory Structure
caddy
(for automated TLS certificates via Let's Encrypt)smtprelay
Let's Encrypt TLS Certs via caddy
Install
go
,xcaddy
, and (optional)serviceman
via https://webinstall.devBuild
caddy
with DNS support (no webserver required). Example w/ DNSimple:~/.config/caddy/Caddyfile
:~/.config/caddy/caddy.env
:caddy
as a service withserviceman
(Linux, macOS, & Windows)(
--cap-net-bind
is only necessary if using default ports 80 & 443)smtprelay config
Create the config file
~/.config/smtprelay/smtprelay.ini
:~/.config/smtprelay/allowed_users.txt
:Test with Curl
serviceman
: