惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
B
Blog
Stack Overflow Blog
Stack Overflow Blog
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
Recent Announcements
Recent Announcements
U
Unit 42
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
腾讯CDC
D
DataBreaches.Net
Microsoft Azure Blog
Microsoft Azure Blog
G
Google Developers Blog
M
MIT News - Artificial intelligence
P
Proofpoint News Feed
罗磊的独立博客
L
LangChain Blog
V
Visual Studio Blog
雷峰网
雷峰网
aimingoo的专栏
aimingoo的专栏
宝玉的分享
宝玉的分享

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Send email from any Linux server in 60 seconds — no SMTP ...
Qasim Muhamm · 2026-05-05 · via DEV Community

You ssh'd into a fresh Linux box and you need to send an email. Maybe a backup completed. Maybe a deploy succeeded. Maybe a process crashed and you want a stack trace in your inbox.

The traditional path: install Postfix, edit main.cf, configure a smart relay, generate SASL credentials, restart the daemon, and pray nothing else on the box uses port 25. That is the 30-minute path.

The 60-second path:

curl -fsSL https://cli.nylas.com/install.sh | bash
~/.config/nylas/bin/nylas auth config --api-key YOUR_KEY
~/.config/nylas/bin/nylas email send --to you@example.com --subject hi --body "From $(hostname)"

Enter fullscreen mode Exit fullscreen mode

Three lines. Zero daemon. Works on every modern Linux distro and macOS.

Why the old path is so slow

Setting up outbound SMTP from scratch involves five separate concerns:

Concern Time Failure mode
Install Postfix or Exim 2 min Distro package conflicts
Configure relayhost 5 min Wrong port, blocked by ISP, DNS lookup
SASL auth to relay 10 min Hashing format, postmap regen
TLS to relay 5 min Cert path, CA bundle
Test send through queue 5 min mqueue stuck, tail /var/log/mail.log

Five places to get it wrong. Most people get it wrong twice before it works.

What the 60-second path skips

The CLI ships a static binary. No package dependencies, no system services, no firewall punches. The send happens over HTTPS to the Nylas API on port 443 — already open in 99% of environments.

Specifically, you are not:

  • Opening port 25 outbound (most cloud providers block this)
  • Setting up STARTTLS to a relay
  • Maintaining sender DKIM/SPF/DMARC keys (the API handles signing)
  • Writing config files in /etc/postfix

Real-world recipes

Cron job that emails on failure

#!/usr/bin/env bash
if /usr/local/bin/run-backup.sh; then
  exit 0
fi

nylas email send --to oncall@yourcompany.com \
  --subject "[FAIL] backup on $(hostname)" \
  --body "$(date): backup failed. See /var/log/backup.log"

Enter fullscreen mode Exit fullscreen mode

systemd OnFailure handler

# /etc/systemd/system/notify-failure@.service
[Unit]
Description=Notify on service failure for %i

[Service]
Type=oneshot
ExecStart=/usr/local/bin/nylas email send --to oncall@yourcompany.com \
  --subject "[%H] %i failed" \
  --body "Check journalctl -u %i for details"

Enter fullscreen mode Exit fullscreen mode

# In any service that should notify on failure:
[Unit]
OnFailure=notify-failure@%n.service

Enter fullscreen mode Exit fullscreen mode

This is exactly the pattern the systemd man pages document for OnFailure, with one less moving part.

Deploy notification from CI

nylas email send --to team@yourcompany.com \
  --subject "✅ Deploy v${VERSION} to prod" \
  --body "https://app.example.com/deploys/${DEPLOY_ID}"

Enter fullscreen mode Exit fullscreen mode

Shell trap on script exit

trap 'nylas email send --to me@example.com --subject "rebuild done on $(hostname)" --body "exit code $?"' EXIT

./long-running-rebuild.sh

Enter fullscreen mode Exit fullscreen mode

What about mailx, msmtp, sendmail?

They are venerable, and on a single machine where you already have a working relay, they are fine. Where they hurt:

  • mailx needs an MTA underneath (Postfix, Exim). Nothing changes about the SMTP setup.
  • msmtp is itself an SMTP client, so you still maintain relay credentials and TLS.
  • sendmail is the historical command, usually backed by Postfix.

The Nylas CLI replaces all three for the "I need to send from a script" use case. There is no relay to maintain because the relay is the API.

The 60-second checklist

# 1. Install
curl -fsSL https://cli.nylas.com/install.sh | bash

# 2. Add to PATH for the session
export PATH="$HOME/.config/nylas/bin:$PATH"

# 3. Auth
nylas auth config --api-key YOUR_KEY

# 4. Test
nylas email send --to you@example.com --subject hi --body "from $(hostname)"

# 5. Verify it landed (should be in your inbox in <30 sec)

Enter fullscreen mode Exit fullscreen mode

If step 5 worked, you are done. Add the binary location to a system-wide PATH (e.g., symlink to /usr/local/bin) if other users on the box need it.

A note for hardened environments

If your server has no outbound HTTPS — air-gapped, restricted egress firewall — the CLI cannot reach the API. In that case, ship messages to an internal queue (or a relay box that does have egress) and let that machine call the CLI. The CLI itself is not the bottleneck; outbound HTTPS is.

Otherwise, this is the cleanest "make this Linux box send mail" setup I have used.

Next steps