これを参考にメール設定。
TNET Raspberry Pi Site/ SMTP Mail Setup
http://rpi.tnet.com/project/faqs/smtp
具体的にはこんな感じで。
sudo apt-get install ssmtp
sudo apt-get install mailutils
sudo apt-get install mpack
sudo apt-get install mailutils
sudo apt-get install mpack
メール送信pi@raspberrypi ~/wemo $ cat /etc/ssmtp/ssmtp.conf## Config file for sSMTP sendmail## The person who gets all mail for userids < 1000# Make this empty to disable rewriting.root=postmaster# The place where the mail goes. The actual machine name is required no# MX records are consulted. Commonly mailhosts are named mail.domain.com#mailhub=smtp.gmail.com:587# Where will the mail seem to come from?#rewriteDomain=# The full hostnamehostname=raspberrypi# Are users allowed to set their own From: address?# YES - Allow the user to specify their own From: address# NO - Use the system generated From: address#FromLineOverride=YESAuthUser=xxxxxx@gmail.comAuthPass=xxxxxxxxxFromLineOverride=YESmailhub=smtp.gmail.com:587UseSTARTTLS=YES
echo "sample text" | mail -s "Subject" username@domain.tld
添付ファイル送信
mpack -s "test" /home/pi/test/somefile.ext username@domain.tld
Crontabに起動時の処理を設定
これで、起動時にifconfigの内容がメールで届きます。実行内容を通知するうるさいメールはMAILTO=""で止めてます。pi@raspberrypi ~/wemo $ crontab -lMAILTO=""
@reboot /home/pi/wemo/reboot-notification
pi@raspberrypi ~/wemo $ cat reboot-notification
#!/bin/bash
echo `sudo ifconfig | mail -s "Reboot-Raspberry" xxxx@xxxxx.com`