Background documentationEvent-Controlled Sending of E-mails Locate this document in the navigation structure

 

You use the SDBMAIL function to send an e-mail to one or more recipients when an event with the defined properties occurs.

SDBMAIL uses Simple Mail Transfer Protocol (SMTP) and the standard RFC 822.

SDBMAIL only evaluates one parameter. This parameter describes the contents and the recipient(s) of the e-mail in XML format.

You define the sender and recipient of the e-mail using the DBM configuration parameter in the database-specific configuration file (refer to: dbm_configset).

DBM Configuration Parameter SDBED_SMTPSENDERAD

This parameter specifies the sender address for the generated e-mail.

DBM Configuration Parameter SDBED_SMTPSERVERS

This parameter defines one or more servers from which the generated e-mail is sent. Specify the server name and, optionally, a port number. If you do not enter a port number, the system uses port 25. Use a comma (and no spaces) to separate entries.

Example Example

<server_name1>[:<port_number1>],<server_name2>[:<port_number2>],...

End of the example.
Syntax of the Execution Command for SDBMAIL

"sdbmail \"<EMAIL><subject_def> <body_def> <recipient_def></EMAIL>\""

<subject_def> :: = <SUBJECT><subject_text></SUBJECT>

<body_def> :: = <BODY><body_text></BODY>

<recipient_def> :: = <recipient_address> | <recipient_address><recipient_address>...

<recipient_address> :: = <RECIPIENT><email_address></RECIPIENT>

Note Note

The parts of the command line that are written as key words (uppercase letters) are XML tags and must include the angle brackets. They replace the variables written in lowercase letters in angle brackets with valid values (see also: Section “Example”).

If the execute command contains spaces, you need to put the command in double quotation marks. If options within an execute command contain quotation marks, the quotation marks must be preceded by a backslash (\).

End of the note.

Option

Description

<event_name>

Event name

<subject_text>

Subject line in e-mail to be sent

<body_text>

Contents of e-mail to be sent

<email_address>

Recipient address of e-mail

Scenario

You want to send an e-mail to operators OLEG and MONA whenever an event of the category ThrowErrorEvent occurs for database DEMODB. The following data applies:

Parameter

Value

Name of event:

Error

Subject line in e-mail:

Error in DEMODB

Contents of e-mail: Error in DEMODB

Date: $DATE$ Time: $EVTTIME$

Recipient of e-mail:

mona@example.com and oleg@example.com

Sender of e-mail:

admin@example.com

SMTP server:

server1.example.com,server2.example.com:25

Recommendation Recommendation

To test the function in the context of the tutorial, specify one or more valid e-mail addresses, to which you have access, for the recipient.

End of the recommendation.

Prerequisites

The file dbm_whitelist.cfg exists in the run directory of the database and is owned by an administrator of the current computer.

For more prerequisites, see Database Manager CLI, event_dispatcher

Procedure

  1. Call Database Manager CLI in session mode, log on as DBM operator OLEG with password MONDAY, and connect to the database DEMODB:

    >dbmcli -u OLEG,MONDAY -d DEMODB

    dbmcli on DEMODB>

  2. Define the DBM configuration parameter SDBED_SMTPSENDERAD:

    dbmcli on DEMODB>dbm_configset SDBED_SMTPSENDERAD admin@example.com

    OK

  3. Define the DBM configuration parameter SDBED_SMTPSERVERS:

    dbmcli on DEMODB>dbm_configset SDBED_SMTPSERVERS server1.example.com,server2.example.com:25

    OK

  4. Create the link between event Error and function SDBMAIL according to the above scenario:

    event_dispatcher ADD Name == offline Command == “SDBMAIL \”<subject>Error in DEMODB<\subject> <body>Error in DEMODB Date: $DATE$ Time:$EVTTIME$</body> <recipient>mona@example.com,oleg@example.com</recipient>

Result

The link has been created. If the event dispatcher is not yet active, activate it now so that this link becomes active and e-mails are sent whenever the event occurs.

Example

More Information

Database Manager CLI, dbm_configset, event_dispatcher