關於 PHP, Linux, Open Source 及個人生活記載的網誌。
RSS icon
  • 透過 shell script 發送 email

    Posted on November 6th, 2007 Sam Tang No comments

    如果想用 shell script 發送郵件,可以用 mail 實現:

    # echo "email content" | mail -s "email subject" you@emaildomain

    以上語句會發送一封標題為 "email subject" 的電郵到 you@emaildomain,其中 "email content" 為電郵內容。

    以下簡單的兩行 shell script 便會將檔案系統使用量,透過電郵發送給指定的電郵信箱:

    #!/bin/sh
    /bin/df -h | /usr/bin/mail -s "server capacity" you@emaildomain

    Leave a reply

    *
    To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
    Click to hear an audio file of the anti-spam word