This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python code
#1
Hello,

I have create a code but i can't send mail. the program detect presence of Bluetooth but don' send mail:

(if my Bluetooth isn't detected tinkerboard test pin22( Infrared captor ) if captor detect somebody it send me mail.
there is part whith adresse mail sender and receiver but i don't write here!)

#######################beginning code#########################
GPIO.setmode(GPIO.BOARD)
GPIO.setup(22,GPIO.IN)

def mail():
    context = ssl.create_default_context()
    with smtplib.SMTP_SSL(smtp_adress, smtp_port, context=context)as server:
        server.login(email_adresse, email_passeword)
        server.sendmail(email_adresse, email_receiver, 'this is teste')
        
 



while 1:
        nearby_devices = bluetooth.discover_devices(duration=8, lookup_names=True,
                                        flush_cache=True, lookup_class=False)
        for addr, name in  nearby_devices:
            if addr != addr1 and name != name1:
                print("not deteced")
                if GPIO.input(22) == 1:
                    mail()
                    print("mail post")
                    break
                 
                                                
            else:
                print("i'm here!")
#####################end code###########################

it run whit Python3.5 .
Can you help me,
thanks,
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)