1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

GỬI MAIL CHO ĐIỆN THOẠI BẰNG RASPBERRY PI NGÔN NGỮ LẬP TRÌNH PYTHON

2 37 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

GỬI MAIL CHO ĐIỆN THOẠI BẰNG RASPBERRY PI NGÔN NGỮ LẬP TRÌNH PYTHON GỬI MAIL CHO ĐIỆN THOẠI BẰNG RASPBERRY PI NGÔN NGỮ LẬP TRÌNH PYTHON GỬI MAIL CHO ĐIỆN THOẠI BẰNG RASPBERRY PI NGÔN NGỮ LẬP TRÌNH PYTHON

CODE RASPBERRY PI (GUI MAIL) import smbus import pygame import smtplib bus = smbus.SMBus(1) pygame.mixer.init() pygame.mixer.music.load("Neverenough.wav") #this is the address in the arduino program address = 0x04 def readMic(): volume = bus.read_byte(address) #number = bus.write_byte_data(address,1) return volume while True: vol = readMic() if vol == 1: vol = if not pygame.mixer.music.get_busy(): pygame.mixer.music.play() sendmail() ############################## # start talking to the SMTP server for Gmail Def sendmail(): s = smtplib.SMTP('smtp.gmail.com', 587) s.starttls() s.ehlo() # now login as my gmail user username='bbsisterK17@gmail.com' password='babycryK17' s.login(username,password) # the email objects replyto='bbsisterK17@gmail.com' # where a reply to will go sendto=['nguyennguyen2919@gmail.com','phuonguyenabatcha@gmail.com'] # list to send to sendtoShow='me@me.com' # what shows on the email as send to subject='HELLO PARENTS' # subject line content="BABY IS CRYING! BABY IS CRYING!" # content # compose the email probably should use the email python module mailtext='From: '+replyto+'\nTo: '+sendtoShow+'\n' mailtext=mailtext+'Subject:'+subject+'\n'+content # send the email s.sendmail(replyto, sendto, mailtext) # we’re done rslt=s.quit() # print the result print('Send successful') ... compose the email probably should use the email python module mailtext='From: '+replyto+' To: '+sendtoShow+' ' mailtext=mailtext+'Subject:'+subject+' '+content # send the email s.sendmail(replyto,... sendmail(): s = smtplib.SMTP('smtp.gmail.com', 587) s.starttls() s.ehlo() # now login as my gmail user username='bbsisterK17@gmail.com' password='babycryK17' s.login(username,password) # the email... replyto='bbsisterK17@gmail.com' # where a reply to will go sendto=['nguyennguyen2919@gmail.com','phuonguyenabatcha@gmail.com'] # list to send to sendtoShow='me@me.com' # what shows on the email as send

Ngày đăng: 16/08/2021, 13:17

Xem thêm:

TỪ KHÓA LIÊN QUAN

w