Skip to content

Scripting BetterEmail

Joe Keenan edited this page Dec 22, 2019 · 13 revisions

You can send email messages from Python scripts in Actions. The following subroutine can be called from within your scripts.
Be sure to put in the correct email address and the deviceID for a BetterEmail SMTP device.

def sendAlertEmail(subject, message):
    bePlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.betteremail")
    if bePlugin.isEnabled():
        bePlugin.executeAction("sendEmail", deviceId=12345678, props={'emailTo':'foo@bar.com', 'emailSubject': subject, 'emailMessage': message})
    return

sendAlertEmail("Test Alert", "This is only a test")

There are additional optional properties you can include:

props = {   
    'emailTo': 'address1, address2', 
    'emailCC': 'address3, address4', 
    'emailBCC': 'address5, address6', 
    'emailSubject': 'Message Subject', 
    'emailAttachments': 'file1, file2, file3', 
    'emailFormat': 'plain'   (or 'html')
    'emailMessage': 'Message text'
}

bePlugin = indigo.server.getPlugin("com.flyingdiver.indigoplugin.betteremail")
if bePlugin.isEnabled():
    bePlugin.executeAction("sendEmail", deviceId=12345678, props=props)
Clone this wiki locally