def send_image(): filename = picroscope.capture() if filename is not None: picroscope.toggle_preview() email = Email(server) email.subject = EMAIL_SUBJECT email.recipient = input("Recipient: ") email.add_attachment(filename) print() try: print("Please wait ...") email.send() except SMTPRecipientsRefused: print("Invalid email address.")