Last active
August 4, 2025 10:39
-
-
Save mstaack/781ac6c9352cfa96340ea5461ae46a8d to your computer and use it in GitHub Desktop.
install mailpit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
VERSION="v1.27.3" | |
ARCH="linux-amd64" | |
ARCHIVE_URL="https://github.com/axllent/mailpit/releases/download/${VERSION}/mailpit-${ARCH}.tar.gz" | |
TMP_DIR="/tmp/mailpit-install" | |
BIN_PATH="/usr/local/bin/mailpit" | |
SERVICE_FILE="/etc/systemd/system/mailpit.service" | |
echo "π¦ Downloading Mailpit ${VERSION}..." | |
# Prepare temp dir | |
mkdir -p "$TMP_DIR" | |
cd "$TMP_DIR" | |
# Download archive | |
curl -sL "$ARCHIVE_URL" -o mailpit.tar.gz | |
# Extract archive | |
tar -xzf mailpit.tar.gz | |
# Find binary | |
if [ ! -f "mailpit" ]; then | |
echo "β Mailpit binary not found after extraction" | |
exit 1 | |
fi | |
# Install binary | |
mv mailpit "$BIN_PATH" | |
chmod +x "$BIN_PATH" | |
# Create system user if missing | |
if ! id "mailpit" &>/dev/null; then | |
echo "π€ Creating system user 'mailpit'..." | |
useradd --system --no-create-home --shell /usr/sbin/nologin mailpit | |
fi | |
# Create systemd unit | |
echo "π Creating systemd service..." | |
cat <<EOF > "$SERVICE_FILE" | |
[Unit] | |
Description=Mailpit - SMTP dev mail server | |
After=network.target | |
[Service] | |
ExecStart=$BIN_PATH | |
Restart=always | |
User=mailpit | |
Group=mailpit | |
Environment=MAILPIT_UI_PORT=8025 | |
Environment=MAILPIT_SMTP_PORT=1025 | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
# Reload systemd and start service | |
echo "π Enabling and starting mailpit service..." | |
systemctl daemon-reexec | |
systemctl daemon-reload | |
systemctl enable mailpit | |
systemctl start mailpit | |
echo "β Mailpit v${VERSION} installed and running!" | |
echo " Web UI: http://localhost:8025" | |
echo " SMTP Port: 1025" | |
# Clean up | |
rm -rf "$TMP_DIR" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment