标签归档:raspberry

让树莓派(raspberry)开机后发送邮件告诉你 IP地址

先写一个python 脚本叫做 sendip.py:
#/bin/env python
# -*-coding:utf8-*-
import socket
import fcntl
import time
import struct
import smtplib
import urllib
import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage

#发送邮件的基本函数,参数依次如下
# smtp服务器地址、邮箱用户名,邮箱秘密,发件人地址,收件人地址(列表的方式),邮件主题,邮件html内容
def sendEmail(smtpserver, username, password, sender, receiver, subject, msghtml):
msgRoot = MIMEMultipart(‘related’)
msgRoot[“To”] = ‘,’.join(receiver)
msgRoot[“From”] = sender
msgRoot[‘Subject’] read more