LoginSignup
172
177

More than 5 years have passed since last update.

[mailコマンド]Linuxからメールを送る

Posted at

1. mailコマンドインストール

yum install -y mailx
  • 必要ならsudoつける
  • -yオプションは任意(付けなければ途中でyes/no選択。つけたら無条件yes)

2. 実際にメールを送る

送信例。

echo "本文" | mail -s "タイトル" -r from@example.com -c cc1@example.com -c cc2@example.com to1@example.com to2@example.com
  • 本文はecho "本文直書き"もしくはcat ファイル名により指定
  • -sオプション:タイトル指定
  • -rオプション:送り主メールアドレス指定
  • -cオプション:Ccで送るメールアドレス指定
    • Ccで複数人に送る場合 → 1件ずつ-cオプションで指定
  • -bオプション:Bccで送るメールアドレス指定
    • Bccで複数人に送る場合 → 1件ずつ-bオプションで指定
  • mailコマンドの最後の引数:送り先メールアドレス指定
    • 複数人にToで送る場合 → 半角スペース区切りでメールアドレス指定
172
177
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
172
177