Linux command
mail 命令
网络
复制后可按需替换文件名、目录或参数。
常用示例
Send email
mail -s "[Subject]" [recipient@example.com]
Send with body
echo "[message]" | mail -s "[Subject]" [recipient@example.com]
Send file contents
mail -s "[Subject]" [recipient@example.com] < [message.txt]
Send with attachment
mail -s "[Subject]" -A [file.pdf] [recipient@example.com]
Read mail
mail
Check specific mailbox
mail -f [/var/mail/user]
说明
mail sends and reads email. It's a basic command-line mail user agent. The tool can send quick emails from scripts. It reads mail from local mailboxes.
参数
- -s _SUBJECT_
- Email subject.
- -A _FILE_
- Attach file.
- -c _ADDR_
- CC recipients.
- -b _ADDR_
- BCC recipients.
- -f _FILE_
- Read from mailbox.
- --help
- Display help information.
FAQ
What is the mail command used for?
mail sends and reads email. It's a basic command-line mail user agent. The tool can send quick emails from scripts. It reads mail from local mailboxes.
How do I run a basic mail example?
Run `mail -s "[Subject]" [recipient@example.com]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -s _SUBJECT_ do in mail?
Email subject.