1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
-
- This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
- project.
-
- Copyright (C) 1998-2018 OpenLink Software
-
- This project is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; only version 2 of the License, dated June 1991.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License along
- with this program; if not, write to the Free Software Foundation, Inc.,
- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-
-->
<refentry id="fn_smtp_send">
<refmeta>
<refentrytitle>smtp_send</refentrytitle>
<refmiscinfo>mail</refmiscinfo>
</refmeta>
<refnamediv>
<refname>smtp_send</refname>
<refpurpose>send message to SMTP server</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_smtp_send">
<funcprototype id="fproto_smtp_send">
<funcdef> <function>smtp_send</function></funcdef>
<paramdef>in <parameter>server</parameter> string</paramdef>
<paramdef>in <parameter>sender</parameter> string</paramdef>
<paramdef>in <parameter>recipient</parameter> string</paramdef>
<paramdef>in <parameter>body</parameter> string</paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_smtp_send">
<title>Description</title>
<para>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.
</para>
<para>
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>'
</para>
<para>
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'
</para>
<example id="examples_smtp_send"><title>Example:</title>
<programlisting>
'Subject: subject message\r\nFrom: sender\r\nTo: recipient\r\nCc:
copy\r\nBcc: copy\n\n body of message'
</programlisting>
<para>
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.
</para>
</example>
<example id="examples_smtp_send"><title>Example:</title>
<programlisting><![CDATA[
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')
);
]]></programlisting>
<para>
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.
</para>
</example>
</refsect1>
</refentry>
|