www.openlinksw.com
docs.openlinksw.com

Book Home

Contents
Preface

Virtuoso Functions Guide

Administration
Aggregate Functions
Array Manipulation
BPEL APIs
Backup
Compression
Cursor
Date & Time Manipulation
Debug
Dictionary Manipulation
Encoding & Decoding
File Manipulation
Free Text
Hashing / Cryptographic
LDAP
Locale
Mail
mime_body
mime_part
mime_tree
nntp_auth_get
nntp_auth_post
nntp_get
nntp_post
pem_certificates_to_...
pop3_get
smime_sign
smime_verify
smtp_send
uuvalidate
Miscellaneous
Number
RDF data
Remote SQL Data Source
Replication
SOAP
SQL
String
Transaction
Type Mapping
UDDI
User Defined Types & The CLR
Virtuoso Java PL API
Virtuoso Server Extension Interface (VSEI)
Web Server & Internet
XML
XPATH & XQUERY

Functions Index

smtp_send

send message to SMTP server
smtp_send (in server string, in sender string, in recipient string, in body string);
Description

Virtuoso can act as an SMTP client. This means that Virtuoso is able to send emails directly to a mail SMTP server. Virtuoso has a simple function to facilitate this. This can be called from stored procedures, VSP pages, triggers etc.

The sender and recipient email addresses must be enclosed with <..> and separated by commas i.e. string '<support@openlinksw.co.uk>,<sales@openlinksw.co.uk>'

The message Body contains headers such as Subject, From, To, Cc, Bcc and then continues with the actual message text itself. New lines can be added using '\r\n'

Example:
'Subject: subject message\r\nFrom: sender\r\nTo: recipient\r\nCc:
copy\r\nBcc: copy\n\n body of message'

Virtuoso will pick up Subject and other headers from the body content. Note that the RFC insists there should be a NULL line between body headers and the message body text.

Example:
smtp_send(
		'mail.example.com:25', 
		'<sender@example.com>',
		'<receiver@example.com>', 
		concat(
		  'X-Mailer: Virtuoso Universal Server\r\n', 
			'Date: ', soap_print_box (now (), '', 1), '\r\n', 
			'Message-ID: <', regexp_replace(cast(now() as varchar), '[- :.]', '', 1, null), '#some.vsp@example.com>\r\n',
			'Subject: This is a test mail...\r\n',
			'From: <sender@example.com>\r\n', 
			'To: <receiver@example.com>\r\n',
			'\n',
			'Hi Receiver, this is a test message from Virtuoso')
	);

A more involved example. It is the responsibility of the developer to ensure that the message is correctly formed, complete with all necessary headers. This example shows a complete use of the function.