LoginSignup
7
7

More than 5 years have passed since last update.

ShellScriptでメール送信

Last updated at Posted at 2014-12-01
sendmail1.sh
#!/bin/sh
to=to@addr.ess
from=from@addr.ess
SUBJECT="題名"
BODY="本文"

echo "${BODY}" | mailx -s "${SUBJECT}" -r ${from} ${to}

or

sendmail2.sh
#!/bin/sh
to=to@addr.ess
from=from@addr.ess
SUBJECT="題名"
FILE="本文ファイル名"

cat "${FILE}" | mailx -s "${SUBJECT}" -r ${from} ${to}

mailxコマンドがない場合はmailを使う(たぶんその場合は-r ${from}では上手くいかない)

7
7
1

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
7
7