Extract the aaimi_email_out.py file to the folder containing your program and open the file.
On line 25 change the system_email to the dedicated gmail account your program will send from.
On line 27 is the password for this account. It's not wise to hard-code passwords into your program files, so I leave this blank, then have my home-automation program prompt for the password on startup. I'll explain this in a moment.
# Dedicated email account for AAIMI to send and receive email
system_email = "YourSystemEmail@gmail.com"
# Password for AAIMI's dedicated Gmail account
system_pass = ""
# User email address
user_email = "yourEmail@email.com"
On line 29 enter your email account, the account that will receive the email alerts.
On line 41 you can change the layout and colors for the emails by modifying the CSS.
On line 51 you can change the HTML tags to adjust the layout. By default the subject is a H1 and the rest of the arguments are paragraph tags.
That's all you need to do in this file, let's import it into your programs.
Import and use AAIMI Email
Open your Python program that needs to send emails. At the top of your code, import AAIMI Email, getpass and time:
If, as suggested you left the password field blank in the aaimi_email file, add the following block of code below the import statement:
When your program starts it will prompt for the password for your system email account.
Next, create a time limit in seconds and a last_email variable to record the time of the last email. This is an important safety feature that sets a time limit for for subsequent emails. If your program somehow ends up in an unintended loop, you don't want it firing off emails one-after-the-other indefinitely.