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 38 0

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

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 2
Dung lượng 24,57 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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

Trang 1

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 = 0

if not pygame.mixer.music.get_busy(): pygame.mixer.music.play()

sendmail()

##############################

# start talking to the SMTP server for Gmail

Trang 2

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@mẹ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: '+replytớ\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')

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

TỪ KHÓA LIÊN QUAN

w