import smtplib
def sendErrorMail(emailAddress,emailAppPassword,type,message):
    if emailAddress!=” and emailAppPassword!=”:
        FROM = emailAddress
        TO = [emailAddress] #must be a list
        SUBJECT = “ENTER SUBJECT TEXT HERE, {type}”.format(type=type)
        # Prepare actual message
        emailMessage = “Subject: {subject}\n\n {text}”.format(
        subject=SUBJECT,text=message)
        try:
            server = smtplib.SMTP(“smtp.gmail.com:587“) #Hello GMAIL
            server.ehlo() #Identifying for the first time
            server.starttls() #Secure transmission of password
            server.login(emailAddress, emailAppPassword)
            server.ehlo() #Identifying again
            server.sendmail(FROM, TO, emailMessage)
            server.close()
        except:
            print(“failed to send mail“)
    else:
        print(“Didn’t send an email. \n Please enter your login details at “
              “the beginning of the script if you want an email sent”)