Skip to main content
Skip table of contents

SMTP Configuration

For sending emails from the CData Virtuality Server, you will need to set up access to an SMTP server.

Prerequisites

You can easily make use of the SMTP functionality of CData Virtuality. There are only a few things that you need to make sure of to activate and use this feature:

  • A working SMTP server somewhere (hosted or on-premise)
  • Access to the folder where the CData Virtuality Server is installed and write permission to its files
  • The SMTP server has to be configured to accept incoming mail from the IP used by the CData Virtuality Server. This might be necessary to configure on very restrictive servers in terms of incoming SMTP connections.

Configuration Steps

Via Studio

The easiest way to configure your SMTP credentials is via the CData Virtuality Studio. Navigate to the Window menu item and select Preferences. Open the SMTP Configuration section and fill in your SMTP details.

Via SQL

You may also configure your SMTP credentials programmatically via SQL by calling the corresponding system procedure:

SQL
CALL "UTILS.setSmtpConfiguration"(
	"hostname" => 'string_hostname',
	"port" => integer_port,
	"ssl" => boolean_ssl,
	"starttls" => boolean_ssl,
	"username" => 'string_username',
	"password" => 'string_password',
	"fromAddr" => 'string_fromAddr'
);;

sendMail

For sending emails, you can use the UTILS.sendMail procedure. Here are several examples:

Simple plain text message

Simple mail

SQL
SELECT RESULT
	FROM table(CALL "views.sendMail"(
		"Recipient" => 'someone@somedomain.net',
		"Subject" => 'testsubject',
		"Body" => 'Some Content'
)) b;;

Reading the contents of a file and sending it as an attachment:

Sending mail with XML file attachment

SQL
WITH c AS (
	SELECT *
		FROM (CALL "file.getFiles"("pathAndPattern" => 'criteo.xml')) b
		)
		SELECT RESULT
			FROM c,
			TABLE(
				CALL "views.sendMail"(
  				  "Recipient" => 'someone@somedomain.net',
  				  "Subject" => 'testsubject',
  				  "Body" => 'Some Content',
 				   "AttachmentNames"=> ARRAY(filePath),
				   "Attachments" => ARRAY(file),
				   "AttachmentMimeTypes" => ARRAY('text/xml')
					)
) b;;

Sending an XLS file

SQL
WITH c AS (
	SELECT *
		FROM (CALL "file.getFiles"("pathAndPattern" => '../mattables.xls')) b
		)
		SELECT RESULT
		FROM c,
		TABLE(
			CALL "views.sendMail"(
 			   "Recipient" => 'someone@somedomain.net',
 			   "Subject" => 'testsubject',
 			   "Body" => 'Some Content',
 			   "AttachmentNames" => ARRAY(filePath),
 			   "Attachments" => ARRAY(file),
 			   "AttachmentMimeTypes" => ARRAY('application/vnd.ms-excel')
				)
) b;;
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.