SkillHub

simple-smtp-mail

v1.0.0

使用msmtp命令行工具通过SMTP发送邮件,认证及服务器设置配置于~/.msmtp/config。

Sourced from ClawHub, Authored by GaoXiang Yu

Installation

Please help me install the skill `simple-smtp-mail` from SkillHub official store. npx skills add HITYGX/simple-smtp-mail

Simple SMTP Mail

Send emails via SMTP using msmtp command-line tool.

Configuration

Create a configuration file at ~/.msmtp/config with the following format:

account default
host <SMTP_SERVER>
port <PORT>
tls on
tls_starttls off
auth on
user <EMAIL_ADDRESS>
password <PASSWORD>
from <EMAIL_ADDRESS>

Common SMTP Settings

Gmail: - SMTP Server: smtp.gmail.com - Port: 465 (SSL) or 587 (TLS) - Note: Use App Password, not your regular password

QQ Mail: - SMTP Server: smtp.qq.com - Port: 465

Outlook/Hotmail: - SMTP Server: smtp.office365.com - Port: 587

163.com: - SMTP Server: smtp.163.com - Port: 465

Installation

1. Install msmtp

macOS:

brew install msmtp

Linux (Debian/Ubuntu):

sudo apt install msmtp

Linux (Fedora/RHEL):

sudo dnf install msmtp

2. Configure SMTP

Edit ~/.msmtp/config:

nano ~/.msmtp/config

3. Set Permissions

chmod 600 ~/.msmtp/config

Sending Email

Basic Email

echo "Body text" | msmtp [email protected]

With Subject

echo -e "Subject: Your SubjectnnBody text" | msmtp [email protected]

With Subject and From Header

echo -e "Subject: Your SubjectnFrom: [email protected] text" | msmtp [email protected]

HTML Content

echo -e "Subject: Your SubjectnContent-Type: text/html; charset=UTF-8nn<html>...</html>" | msmtp [email protected]

Testing

Check if SMTP server is reachable:

msmtp --file=~/.msmtp/config --serverinfo

Troubleshooting

  • "Account not found": Check your config file path with --file flag
  • "Authentication failed": Verify username and password (or App Password)
  • "Connection refused": Check port number and firewall settings
  • "TLS certificate error": Try tls_certcheck off in config (not recommended for production)