Raspberry PiのIPアドレスを自動でメールに送信する(CNS編)
1555 ワード
SFC生にとってラズパイは無くてはならない
だがCNSでデモしようとするとIPアドレスの確認がめんどい。
自動的ににIPアドレスをメールで送ってほしい。
sSMTPを導入
sudo apt-get install sSMTP
sSMTPを設定する
sudo nano /etc/ssmtp/ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
[email protected]
# 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.sfc.keio.ac.jp:465
# Where will the mail seem to come from?
rewriteDomain=sfc.keio.ac.jp
# The full hostname
hostname=hoge
# 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=YES
AuthUser=ログイン名
AuthPass=メールパスワード
UseTLS=YES
ネットワークが上がったら自動でメールを送るスクリプトを書く
sudo nano /etc/network/if-up.d/ipmail
#! /bin/bash
sleep 30s
ip addr | mail -s "ip is..." "送りたいアドレス@sfc.keio.ac.jp"
30秒くらいスリープを入れないと、ネットが上がってもIPアドレスが取れてなかったりして送信に失敗するので。
Author And Source
この問題について(Raspberry PiのIPアドレスを自動でメールに送信する(CNS編)), 我々は、より多くの情報をここで見つけました https://qiita.com/jintomo/items/a79cd5be72b3382d63af著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .