'how can I make my script to send email to myself when I input incorrecet password?

how can I send an Email to myself to notify if the password was not correct?

This is the whole code without the smtp module with sending emails. what should I do to make it work?

import PyPDF2 as p

output = p.PdfFileWriter()

#Reading the Input Pdf File

input_pdf = input("Enter your input file name: ")
input_stream = p.PdfFileReader(open(input_pdf + ".pdf", "rb"))

#Extracting Pages

for i in range(0, input_stream.getNumPages()):
  output.addPage(input_stream.getPage(i))

# Required Params for Output File

name = input("what name do you want to give the file? ")
output_stream = open(name + ".pdf", "wb")

# Encrypt Output file

passw = input("Enter Password for the pdf file: ")
output.encrypt(passw, use_128bit= True)
output.write(output_stream)
output_stream_close()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source