http://www.zorba-xquery.com/modules/email/smtp

Description

Before using any of the functions below please remember to import the module namespace:

import module namespace smtp = "http://www.zorba-xquery.com/modules/email/smtp";
This module can be used for sending emails. The SMTP module contains only one public function that receives two parameters. The SMTP server access information passed as an hostInfo element and the email message representation as a message element. For a quick start see the examples associates with the send(...) function. For a complete specification read, the description and the documentation associated with this function.

Module code

Here is the actual XQuery module code.

Imported Schemas

Please note that the schemas are not automatically imported in the modules that import this module.

In order to import and use the schemas, please add:

import schema namespace email =  "http://www.zorba-xquery.com/modules/email";

See also

Authors

Sorin Nasoi, Daniel Thomas

Version Declaration

xquery version "3.0" encoding "utf-8";

Namespaces

anhttp://zorba.io/annotations
emailhttp://www.zorba-xquery.com/modules/email
smtphttp://www.zorba-xquery.com/modules/email/smtp
verhttp://zorba.io/options/versioning

Function Summary

send($host-info as element(email:hostInfo), $message as element(email:message)) as empty-sequence()

This function sends an email message from the specified account.

send-impl($host-info as element(email:hostInfo), $message as element(email:message)) as empty-sequence() external

Functions

send#2

declare %an:sequential function smtp:send(
    $host-info as element(email:hostInfo),
    $message as element(email:message)
) as empty-sequence()
This function sends an email message from the specified account. The hostName child element of $host-info must have the form: remote_system_name [":" port] [flags]. This syntax is part of the Remote names syntax defined in the UW IMAP toolkit. The remote_system_name and flags fragments are explained in the section III of this document. For example the hostName could look like:
  • <hostName>smtp.gmail.com:587/tls/novalidate-cert<hostName>
  • <hostName>[209.85.129.111]:587/tls/novalidate-cert<hostName>
The $host-info parameter could then look like this:
 <hostInfo>
   <hostName>smtp.gmail.com:587/tls/novalidate-cert</hostName>
   <userName>username</userName>
   <password>password</password>
 </hostInfo>
 
For a complete of the structure of an email message, see the imported email schema: http://www.zorba-xquery.com/modules/email All the data passed to this function does not need to be validated. The only requirement is that they have a valid format and are in the correct namespace according to the schema: http://www.zorba-xquery.com/modules/email.

Parameters

  • $host-info

    The SMTP host, user name, and password.

  • $message

    The message to send as defined in the email XML schema.

Returns

  • empty-sequence()

    The function is declared as sequential and has side-effects. It returns the empty sequence.

Errors

  • smtp:SMTP0001

    The message format is invalid.

  • smtp:SMTP0002

    The message has no recipient.

  • smtp:SMTP0003

    The message could not be sent.

  • smtp:SMTP9999

    If any other error occurs.

  • err:XQDY0027

    If the values of the arguments are not not valid according to the email schema: http://www.zorba-xquery.com/modules/email

Examples

send-impl#2

declare %:private %an:sequential function smtp:send-impl(
    $host-info as element(email:hostInfo),
    $message as element(email:message)
) as empty-sequence() external

Returns

  • empty-sequence()