?????Linux?????Gmail SMTP?????????????????
???????????? ???????[ 2016/3/9 10:51:41 ] ?????????????? Linux
?????????????????? Linux ???????????????????????????????????????????????????????????????£??? Cachet?????????????? Monit????????????? RAID mdadm???????????????????? ???????????? ???????? ??????????????????????? SMTP ?????????????????????????
???????? Gmail ?????????? ??? SMTP ?????? ?????????????з????????????????????????? Gmail ?? SMTP ??????????????????????ɡ?
??????? Gmail ?? SMTP ?????????????Щ???????Щ????????????????Щ???????÷?????????????????????????????????????????????????????? 100 ???????????????????????? 500 ??????????????????????????????????????????????????????????????????κ???????????? Gmail ??????????????????????????Gmail ?? SMTP ????????????????????????????????????????????????
????????????????????????? ????? Linux ????????? Gmail ?? SMTP ?????? ???
????Google Gmail SMTP ??????????
???????????????????????? Gmail ?? SMTP ??????????????????μ????????????????
???????????????? ??SMTP ????????: smtp.gmail.com
??????????: ??
??????e??????: ??
?????????: ??? Gmail ??? ID ?????? “alice” ????????????? alice@gmail.com??
????????: ??? Gmail ????
???????: 587
??????е????????????????????????????????????????????Щ?? Linux ????? Gmail SMTP ????????????????
???????????з??????
?????????????????????????????????????????? Gmail SMTP ?????????????з??????????????????????????? mutt ?????????????????
???????? mutt??
???????? Debian-based ????
????$ sudo apt-get install mutt
???????? Red Hat based ????
????$ sudo yum install mutt
??????????? mutt ?????????~/.muttrc??????????????????????????? Gmail SMTP ????????????? <gmail-id> ?滻??????? Gmail ID?????????????????????????????????????????
????$ vi ~/.muttrc
????set from = "<gmail-id>@gmail.com"
????set realname = "Dan Nanni"
????set smtp_url = "smtp://<gmail-id>@smtp.gmail.com:587/"
????set smtp_pass = "<gmail-password>"
?????????????? mutt ????????????
????$ echo "This is an email body." | mutt -s "This is an email subject" alice@yahoo.com
??????????????????????????? “-a” ???
????$ echo "This is an email body." | mutt -s "This is an email subject" alice@yahoo.com -a ~/test_attachment.jpg
??????? Gmail SMTP ????????ζ??????????????? Gmail ?????????????仰?????????????? Gmail ??????????????????????????????????????????????????????? Gmail SMTP ???????
??????????????????????????
??????????? ??????÷???????VPS?? ??????Щ???????????????? VPS ????????????????????????????????????о????????? VPS ??????????????????????????????????? VPS ???????? systemd??????????????????????????????????? systemd ???????
?????????????????? reboot_notify.sh????????????????
????$ sudo vi /usr/local/bin/reboot_notify.sh
????#!/bin/sh
????echo "`hostname` was rebooted on `date`" | mutt -F /etc/muttrc -s "Notification on `hostname`" alice@yahoo.com
????$ sudo chmod +x /usr/local/bin/reboot_notify.sh
?????????????У?????? “-F” ???????????????? mutt ???????λ?á????????????? /etc/muttrc ?????????????????????????? Gmail SMTP ?????
?????????????????????????????? systemd ????
????$ sudo mkdir -p /usr/local/lib/systemd/system
????$ sudo vi /usr/local/lib/systemd/system/reboot-task.service
????[Unit]
????Description=Send a notification email when the server gets rebooted
????DefaultDependencies=no
????Before=reboot.target
????[Service]
????Type=oneshot
????ExecStart=/usr/local/bin/reboot_notify.sh
????[Install]
????WantedBy=reboot.target
??????????????????????÷???
????$ sudo systemctl enable reboot-task
????$ sudo systemctl start reboot-task
????????????????? VPS ????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11