Mailer objects are used to send email using a client provided secure SMTPS Server URL and Credentials.
Mailer objects are added to ODE Actions and Recording Sinks and Taps enabling them to send email on specific events. Queuing of the event data occurs in the Action's/Component's real time context, while the tasks of assembling the message and uploading to the SMTP server are performed in a low priority background thread. Messages that fail to send will be purged from the queue, dropped and logged as an ERROR.
The relationship between Mailers and Actions/Components is many to many as multiple Mailers can be added to a single Action/Component and the same Mailer can be added to multiple Actions/Components.
Mailers are created by calling the constructor dsl_mailer_new
. Once created, they must be set up with a Server URL, Credentials, etc., prior to use. Mailers are destructured by calling dsl_mailer_delet
e or dsl_mailer_delete_all
.
- Email Action - added to the Action on construction with
dsl_ode_action_email_new
. - Image Capture Actions - added to both Frame and Object Capture Actions with
dsl_ode_action_capture_mailer_add
and removed withdsl_ode_action_capture_mailer_remove
. - Smart Recording Tap - added with
dsl_tap_record_mailer_add
and removed withdsl_tap_record_mailer_remove
. - Smart Recording Sink - added with
dsl_sink_record_mailer_add
and removed withdsl_sink_record_mailer_remove
IMPORTANT! if using GMAIL, it is STRONGLY advised that you create a new, free Gmail account -- that is separate/unlinked from all your other email accounts -- strictly for the purpose of sending ODE Event data uploaded from DSL. Then, add your Personal email address as a To
address to receive the emails.
Gmail considers regular email programs (i.e Outlook, etc.) and non-registered third-party apps to be "less secure". The email account used for sending email must have the "Allow less secure apps" option turned on. Once you've created this new account, you can go to the account settings and enable Less secure app access.
The Gmail secure SMTP server URL is smtps://smtp.gmail.com:465
. Port 465
requires SSL to be enabled which is set by default. See dsl_smtp_ssl_enabled_get
and dsl_smtp_ssl_enabled_set
The following example assumes that all retval
values are checked before proceeding to the next call.
# Create a new Mailer Object
retval = dsl_mailer_new('my-mailer')
# Setup the Server URL
retval = dsl_mailer_server_url_set('my-mailer', 'smtps://smtp.gmail.com:465')
# Using the credentials for your new Gmail SMTP account
retval = dsl_mailer_credentials_set('my-mailer', user_name, password)
# Set the From email address, again using the new SMTP account.
retval = dsl_mailer_address_from_set('my-mailer', '', '[email protected]')
# Add your personal email account as a To address.
# Optionally, add other To and Cc addresses.
retval = dsl_mailer_address_to_add('my-mailer', to_name, to_address)
# queue a test message to be sent out to ensure all settings are correct
retval = dsl_mailer_test_message_send('my-mailer')
Constructors:
Destructors:
Methods
dsl_mailer_enabled_get
dsl_mailer_enabled_set
dsl_mailer_credentials_set
dsl_mailer_server_url_get
dsl_mailer_server_url_set
dsl_mailer_ssl_enabled_get
dsl_mailer_ssl_enabled_set
dsl_mailer_address_from_get
dsl_mailer_address_from_set
dsl_mailer_address_to_add
dsl_mailer_address_to_remove_all
dsl_mailer_address_cc_add
dsl_mailer_address_cc_remove_all
dsl_mailer_test_message_send
dsl_mailer_exists
dsl_mailer_list_size
The following return codes are used by the SMTP API
#define DSL_RESULT_MAILER_RESULT 0x00500000
#define DSL_RESULT_MAILER_NAME_NOT_UNIQUE 0x00500001
#define DSL_RESULT_MAILER_NAME_NOT_FOUND 0x00500002
#define DSL_RESULT_MAILER_THREW_EXCEPTION 0x00500003
#define DSL_RESULT_MAILER_IN_USE 0x00500004
#define DSL_RESULT_MAILER_SET_FAILED 0x00500005
#define DSL_RESULT_MAILER_PARAMETER_INVALID 0x00500006
The following constant values are used by the SMTP API
#define DSL_MAILER_MAX_PENDING_MESSAGES 10
DslReturnType dsl_mailer_new(const wchar_t* name);
The constructor creates a uniquely named, uninitialized Mailer Object. The Mailer must be set up with a Server URL, Credentials, and Email Addresses before first use.
Parameters
name
- [in] unique name for the Mailer to create.
Returns
DSL_RESULT_SUCCESS
on successful creation. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_new('my-mailer')
DslReturnType dsl_mailer_delete(const wchar_t* name);
This destructor deletes a single, uniquely named Mailer. The destructor will fail if the Mailer is currently in-use
by one or more Actions or Components.
Parameters
name
- [in] unique name of the Mailer to delete.
Returns
DSL_RESULT_SUCCESS
on successful deletion. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_delete('my-mailer')
DslReturnType dsl_mailer_delete_all();
This destructor deletes all Mailers currently in memory. The destructor will fail if any one of the Mailers is currently in-use
by one or more Actions or Components..
Returns
DSL_RESULT_SUCCESS
on successful deletion. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_delete_all()
DslReturnType dsl_mailer_enabled_get(const wchar_t* name, boolean* enabled);
This service queries the Mailer for its current enabled state. Mailers are automatically disabled if and while their outgoing queue size exceeds DSL_MAILER_MAX_PENDING_MESSAGES
. Services are enabled by default.
Parameters
name
- [in] unique name of the Mailer to query.enabled
- [out] true if the Mailer is currently enabled, false otherwise.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval, enabled = dsl_mailer_enabled_get('my-mailer')
DslReturnType dsl_mailer_enabled_set(const wchar_t* name, boolean enabled);
This service sets the enabled state for the named Mailer object. Setting the state to true while the outgoing queue size exceeds DSL_SMTP_MAX_PENDING_MESSAGES
will return DSL_RESULT_FAILURE
. Mailers are enabled by default.
Parameters
name
- [in] unique name of the Mailer to update.enabled
- [in] set to true to enable the Mailer, false to disable.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_enabled_set('my-mailer', True)
DslReturnType dsl_mailer_credentials_set(const wchar_t* name,
const wchar_t* username, const wchar_t* password);
This service is used to set the SMTP account credentials, username and password, for all subsequent emails sent by the Mailer.
Parameters
name
- [in] unique name of the Mailer to update.username
- [in] username for the SMTP account.password
- [in] password for the same account.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_credentials_set('my-mailer',
'my-dsl-smtp-account', 'my-dsl-smtp-password')
DslReturnType dsl_mailer_server_url_get(const wchar_t* name,
const wchar_t** server_url);
This service gets the current Server URL in use by the named Mailer. The service will return an empty string until the URL is set by calling dsl_mailer_server_url_set.
Parameters
name
- [in] unique name of the Mailer to query.server_url
- [out] current Server URL in use.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval, server_url = dsl_mailer_server_url_get('my-mailer')
DslReturnType dsl_mailer_server_url_set(const wchar_t* name,
const wchar_t* server_url);
This service sets the Server URL to use for all subsequent emails sent out by the named Mailer.
Parameters
name
- [in] unique name of the Mailer to update.server_url
- [in] new Server URL to use.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_server_url_set('my-mailer',
'smtps://smtp.gmail.com:465')
DslReturnType dsl_mailer_address_from_get(const wchar_t* name,
const wchar_t** display_name, const wchar_t** address);
This service gets the current From
address in use by the named Mailer. Both the display_name and address parameters will return an empty string until set with a call to dsl_mailer_address_from_set.
Parameters
name
- [in] unique name of the Mailer to query.display_name
- [out] returns the display name (optional) for theFrom
address in use.address
- [out] returns the email address in use.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval, display_name, address = dsl_mailer_address_from_get('my-mailer')
DslReturnType dsl_mailer_address_from_set(const wchar_t* name,
const wchar_t* display_name, const wchar_t* address);
This service sets the From
address to use for all subsequent emails by the name Mailer.
Parameters
name
- [in] unique name of the Mailer to update.display_name
- [in] the display name (optional) to use for theFrom
address.address
- [in] the email address to use. Will be set by the server if omitted.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_address_from_set('my-mailer',
'Joe Blow', '[email protected]')
DslReturnType dsl_mailer_ssl_enabled_get(const wchar_t* name, boolean* enabled);
This service gets the SSL enabled setting for the named Mailer. SSL is enabled by default
Parameters
name
- [in] unique name of the Mailer to query.enabled
- [out] true if SSL is currently enabled, false otherwise.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval, enabled = dsl_mailer_ssl_enabled_get('my-mailer')
DslReturnType dsl_mailer_ssl_enabled_set(const wchar_t* name, boolean enabled);
This service sets the SSL enabled state for the named Mailer. SSL is enabled by default.
Parameters
name
- [in] unique name of the Mailer to update.enabled
- [in] set to true to enable SSL, false to disable.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_ssl_enabled_set('my-mailer', True)
DslReturnType dsl_mailer_address_to_add(const wchar_t* name,
const wchar_t* display_name, const wchar_t* address);
This service adds a To
address to use for all subsequent emails.
Parameters
name
- [in] unique name of the Mailer to update.display_name
- [in] the display name (optional) to use for theTo
address.address
- [in] the email address to add.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_address_to_add('my-mailer',
'Jane Doe', '[email protected]')
DslReturnType dsl_mailer_address_to_remove_all(const wchar_t* name);
This service removes all To
addresses from the named Mailer. At least one To
address must exist for email to be sent out.
Parameters
name
- [in] unique name of the Mailer to update.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_address_to_remove_all('my-mailer')
DslReturnType dsl_mailer_address_cc_add(const wchar_t* name,
const wchar_t* display_name, const wchar_t* address);
This service adds a Cc
address to use for all subsequent emails by the named Mailer. Cc
addresses are optional.
Parameters
name
- [in] unique name of the Mailer to update.display_name
- [in] the display name (optional) to use for theCc
address.address
- [in] the email address to add.
Returns
DSL_RESULT_SUCCESS
on successful add. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_address_cc_add('my-mailer',
'Jane Doe', '[email protected]')
DslReturnType dsl_mailer_address_cc_remove_all(const wchar_t* name);
This service removes all Cc
addresses from the named Mailer. Cc
addresses are optional.
Parameters
name
- [in] unique name of the Mailer to update.
Returns
DSL_RESULT_SUCCESS
on successful call. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_address_cc_remove_all('my-mailer')
DslReturnType dsl_mailer_test_message_send(const wchar_t* name);
This service sends a test message using the current SMTP settings and email addresses: From
, To
, and Cc
.
Note: The message will not be sent until the main_loop
has been started.
Parameters
name
- [in] unique name of the Mailer to test.
Returns
DSL_RESULT_SUCCESS
on successful queue. One of the Return Values defined above on failure.
Python Example
retval = dsl_mailer_test_message_send('my-mailer')
boolean dsl_mailer_exists(const wchar_t* name);
This service is used to determine if a named Mailer currently exists in memory.
Parameters
name
- [in] unique name of the Mailer to test.
Returns
true
if the Mailer exists, false otherwise.
Python Example
exists = dsl_mailer_exists('my-mailer')
uint dsl_mailer_list_size();
This service returns the current number of Mailers in memory.
Returns
- The current number of mailers in memory.
Python Example
num_mailers = dsl_mailer_list_size()
- List of all Services
- Pipeline
- Player
- Source
- Tap
- Dewarper
- Preprocessor
- Inference Engine and Server
- Tracker
- Segmentation Visualizer
- Tiler
- Demuxer and Splitter Tees
- Remuxer
- On-Screen Display
- Sink
- Branch
- Component
- GST Element
- Pad Probe Handler
- ODE Trigger
- ODE Accumulator
- ODE Acton
- ODE Area
- ODE Heat-Mapper
- Display Type
- Mailer
- WebSocket Server
- Message Broker
- Info API