<apidoc:module name="SMTPClient" xmlns:apidoc="http://marklogic.com/xdmp/apidoc"><apidoc:summary access="public">
Implements the send function.
</apidoc:summary><apidoc:function name="email" type="builtin" lib="xdmp" category="Extension" subcategory="Extension" hidden="false" bucket="MarkLogic Built-In Functions">
    <apidoc:summary>
  Send an email in an XQuery program.  A valid SMTP Relay must be
  configured in the Groups page of the Admin Interface for the email to be
  sent. The format of the email message must be an XML file that
  complies with the schema files listed below.
</apidoc:summary>
    <apidoc:params>
      <apidoc:param name="message" type="node()" optional="false">
  An XML representation of an email message to send.  The message must
  comply with the XML schemas defined in the following schema files:
  <ul xmlns="http://www.w3.org/1999/xhtml">
	  <li><code><em>install_dir</em>/Config/email-xml.xsd</code></li>
	  <li><code><em>install_dir</em>/Config/rfc822.xsd</code></li>
	</ul>
  where <code xmlns="http://www.w3.org/1999/xhtml"><em>install_dir</em></code> is the directory in which
  MarkLogic Server is installed.
</apidoc:param>
    </apidoc:params>
    <apidoc:privilege>
  http://marklogic.com/xdmp/privileges/xdmp-email
</apidoc:privilege>
    <apidoc:return>empty-sequence()</apidoc:return>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
This example demonstrates sending a message with 
HTML content.
   
xdmp:email(
&lt;em:Message 
 xmlns:em="URN:ietf:params:email-xml:" 
 xmlns:rf="URN:ietf:params:rfc822:"&gt;
  &lt;rf:subject&gt;Sample HTML Email&lt;/rf:subject&gt;
  &lt;rf:from&gt;
    &lt;em:Address&gt;
      &lt;em:name&gt;MarkLogic&lt;/em:name&gt;
      &lt;em:adrs&gt;marklogic@yourdomain&lt;/em:adrs&gt;
    &lt;/em:Address&gt;
  &lt;/rf:from&gt;
  &lt;rf:to&gt;
    &lt;em:Address&gt;
      &lt;em:name&gt;System Administrator&lt;/em:name&gt;
      &lt;em:adrs&gt;admin@yourdomain&lt;/em:adrs&gt;
    &lt;/em:Address&gt;
  &lt;/rf:to&gt;
  &lt;em:content&gt;
    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; 
      &lt;head&gt;
        &lt;title&gt;Test HTML message&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
        &lt;h1&gt;Test HTML message&lt;/h1&gt;
        &lt;p&gt;Here is a simple paragraph&lt;/p&gt;
      &lt;/body&gt; 
    &lt;/html&gt;
  &lt;/em:content&gt;
&lt;/em:Message&gt;)

</pre></apidoc:example>
    <apidoc:example><pre xml:space="preserve" xmlns="http://www.w3.org/1999/xhtml">
This example demonstrate sending a message with 
plain text content. 

xdmp:email(
&lt;em:Message 
 xmlns:em="URN:ietf:params:email-xml:" 
 xmlns:rf="URN:ietf:params:rfc822:"&gt;
  &lt;rf:subject&gt;Sample Plain Text Email&lt;/rf:subject&gt;
  &lt;rf:from&gt;
    &lt;em:Address&gt;
      &lt;em:name&gt;MarkLogic&lt;/em:name&gt;
      &lt;em:adrs&gt;marklogic@yourdomain&lt;/em:adrs&gt;
    &lt;/em:Address&gt;
  &lt;/rf:from&gt;
  &lt;rf:to&gt;
    &lt;em:Address&gt;
      &lt;em:name&gt;System Administrator&lt;/em:name&gt;
      &lt;em:adrs&gt;admin@yourdomain&lt;/em:adrs&gt;
    &lt;/em:Address&gt;
  &lt;/rf:to&gt;
  &lt;em:content xml:space="preserve"&gt;
This is a sample email with a plain text body.
&lt;/em:content&gt;
&lt;/em:Message&gt;)

</pre></apidoc:example>
  </apidoc:function></apidoc:module>