User Tools

Site Tools


Send Email

Sends an email via the SMTP server and password configured in the Email Preferences tab of the preferences. The verb can send simple text emails, or can include HTML email and inline attachments of XTdb graphs as well as video snapshots from Video Pitcher. The text of the email can also use Advanced Label syntax to include data from any unit into the template. The template text can be generated in your script or loaded from a file on disk for easier editing.


send email [list of text, text, or file] pass either the text of the email or a list of lines that will be concatenated and send as the email. If you pass a file reference then that file will be loaded as a template. You can then use the with advanced label processing to fill in any data that you wish and place inline graphs or video snaps.


[text] the subject of the email. If omitted will be filled in as “Message from XTension”

email address

[text or list of text] If omitted the default address entered in the preferences will be used. This can be a single string containing the address or a list containing multiple addresses to send the email to.

email name

[text or list of text] If not specified the default name from the preferences will be used. This is the persons name, not the email address which should be specified in the email address parameter. If you specify one, you should include the other. The 2 lists of names and email addresses must have the same number of entries.


[boolean] Add “with html” to specify that the source text you passed or file contains html. Otherwise the email will be sent as plain text.

attach files

[file or list of files] A file or list of files that you wish to attach to the email. If you also include the with inline parameter below then you can link to the files in an HTML email the cid will be “file” and a number indicating the index into this list. So if you included “someFile.jpg” you could render it inside an html email by including the source <img src=“cid:file1.jpg”> if you don’t include it inline then it will render at the end of the email.

attach graphs

[text or list of text] The name of or list of names of XTdb graphs you wish to include in the email. If you also include the with inline parameter below then you can render the graphs inline with the cid of “graph” and the index into this list. for example <img src=“cid:graph1”> <img src=“cid:graph2”>

attach snapshot

[text or list of text] the name of or list of names of Video Pitcher streams to capture frames from and include in the email. Use the frame count option below to specify the number of frames to capture and then send in the email. Use the resize parameter to reduce the size of the captures to better fit in email. If the inline parameter is included then you can include them inline in an html email via the link <img src=“cid:image1”> etc.


[boolean] if the attachments should be included inline and be available for including in formatted HTML or without this they will be included as any other attachment.


[integer] the percent of the reduction in size to be applied to any graph or video snap being included in the email. With retina capable graphs and 1080p video you may wish to reduce their size by some amount in order to make email servers not reject the email due to size.

advanced label

[boolean] if specified with advanced label then the text will be processed for Advanced Label syntax and any live unit data can be included in the email that way.

frame count

[integer] how many frames of video to capture before sneding them in an email. If not included the default is 3 frames.


Simplest email alert:

send email “glass break sensor in living room” subject “security alert”

Simple email including 3 video snapshots from a video stream. 3 frames will be captured and included as regular attachments in the email.

send email “doorbell was pushed at “ & (current date) as text subject “Front Door Bell” ¬
  attach snapshot “video: frontdoor” frame count 3

Same as above, but capture from 2 different video streams and resize the frames to 25% to make thumbnails of them and not send an email larger than is allowed by the SMTP servers. This can be especially important when sending images from cameras that produce 1080 or larger video.

send email “doorbell was pushed at “ & (current date) as text subject “Front Door Bell” ¬
  attach snapshot {“video: frontdoor”, “video: driveway”} frame count 3 resize 25

Send a summary email with an XTdb graph included as an attachment: Since we have XTdb set to create retina sized graphs we want to resize by 50% to make a graph that will fit in an email properly. This assumes an XTdb graph named “24 hour electric use“

send email “Electric Use for “ & (current date) as text subject “Electric Use Summary” ¬
  attach graphs “24 hour electric use” resize 50

Using advanced syntax you can include current values from units as they are when the email is sent: Since advanced label syntax requires quotes you must escape them inside the string.

send email “fridge temp is <value unit=\”fridge temp is: \”>” subject “Fridge Temp Excession!” with Advanced Label

Examples of HTML formatted emails and inline attachments are coming.

dictionary/human/sendemail.txt · Last modified: 2023/02/13 14:52 by