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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
|
<?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_pop3_get">
<refmeta>
<refentrytitle>pop3_get</refentrytitle>
<refmiscinfo>mail</refmiscinfo>
</refmeta>
<refnamediv>
<refname>pop3_get</refname>
<refpurpose>get messages from a POP3 server</refpurpose>
</refnamediv>
<refsynopsisdiv>
<funcsynopsis id="fsyn_pop3_get">
<funcprototype id="fproto_pop3_get">
<funcdef>array <function>pop3_get</function></funcdef>
<paramdef>in <parameter>host</parameter> varchar</paramdef>
<paramdef>in <parameter>user</parameter> varchar</paramdef>
<paramdef>in <parameter>password</parameter> varchar</paramdef>
<paramdef>in <parameter>buffer_size</parameter> integer</paramdef>
<paramdef><optional>in <parameter>command</parameter> varchar</optional></paramdef>
<paramdef><optional>in <parameter>exclude_uidl_list</parameter> vector</optional></paramdef>
</funcprototype>
</funcsynopsis>
</refsynopsisdiv>
<refsect1 id="desc_pop3_get"><title>Description</title>
<para><function>Pop3_get</function> is used to retrieve and delete messages from a server
running the Post Office Protocol version 3 as defined in rfc1725. In its default form it
returns a vector of vectors containing messages retrieved from the POP3 server.
Each vector within the vector contains a pair of <type>VARCHAR</type> UIDL and
<type>VARCHAR</type> Message body, i.e. to get the message body of the second message retrieved,
one would use <computeroutput>aref (aref (msg_vec, 1), 1)</computeroutput>.
Total length of messages retrieved will not exceed the value of <parameter>buffer_size</parameter>
parameter in bytes.</para>
<para>The optional parameter <parameter>command</parameter> can be used to control output
or delete messages. When <parameter>command</parameter>
is passed a <type>VARCHAR</type> 'uidl', <function>pop3_get</function> outputs single
vector containing <type>VARCHAR</type> UIDLs. The <parameter>buffer_size</parameter> constraint
is effective here. Thus, the vector will only contain UIDLs of messages whose total message text
length does not exceed <parameter>buffer_size</parameter> bytes. These message lengths are
accumulated in the order returned by the POP3 server.</para>
<para>Command 'delete' will cause retrieved messages to be deleted from the server
after retrieval.</para>
</refsect1>
<refsect1 id="params_pop3_get"><title>Parameters</title>
<refsect2>
<title>host</title>
<para>The host to connect with. IP address or hostname:port. There is no default for port, so to connect to the standard port for POP3, use <hostname/IP address>:110</para>
</refsect2>
<refsect2>
<title>user</title>
<para><type>string</type> user id in remote host.</para>
</refsect2>
<refsect2>
<title>password</title>
<para><type>string</type> password in remote host.</para>
</refsect2>
<refsect2>
<title>buffer_size</title>
<para><type>integer</type> maximum total length of message text for
messages/uidls to be retrieved.</para>
</refsect2>
<refsect2>
<title>command</title>
<para>Command <type>string</type>. Valid values are empty, 'uidl'
or 'delete'</para>
</refsect2>
<refsect2>
<title>exclude_uidl_list</title>
<para>A <type>vector</type> containing UIDLs. A message whose UIDL appears in this
list will not be retrieved or deleted.</para>
</refsect2>
</refsect1>
<refsect1 id="ret"><title>Return Types</title>
<para>A vector of vectors containing UIDL/Message text <type>strings</type> or
a 'flat' vector containing UIDL <type>strings</type>.</para>
</refsect1>
<refsect1 id="errors_pop3_get"><title>Errors</title>
<table><title>Errors signalled by</title>
<tgroup cols="4">
<thead><row><entry>SQLState</entry><entry>Error Code</entry><entry>Error Text</entry><entry>Description</entry></row></thead>
<tbody>
<row>
<entry><errorcode>2E000</errorcode></entry>
<entry><errorcode>PO001</errorcode></entry>
<entry><errorname>Cannot resolve host in pop3_get</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08001</errorcode></entry>
<entry><errorcode>PO002</errorcode></entry>
<entry><errorname>Cannot connect in pop3_get</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO003</errorcode></entry>
<entry><errorname>No response from remote POP3 server</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO004</errorcode></entry>
<entry><errorname>Not valid user in remote POP3 server</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO005</errorcode></entry>
<entry><errorname>UIDL command to remote POP3 server failed</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO006</errorcode></entry>
<entry><errorname>Could not get output of UIDL from remote POP3 server.</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO007</errorcode></entry>
<entry><errorname>LIST command to remote POP3 server failed.</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO008</errorcode></entry>
<entry><errorname>Could not get output of LIST from remote POP3 server.</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode></errorcode></entry>
<entry><errorcode>PO009</errorcode></entry>
<entry><errorname></errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO010</errorcode></entry>
<entry><errorname>Failed reading output of LIST command on remote POP3 server</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO011</errorcode></entry>
<entry><errorname>Could not DELE messages from remote POP3 server</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO012</errorcode></entry>
<entry><errorname>Could not QUIT from remote POP3 server</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08000</errorcode></entry>
<entry><errorcode>PO013</errorcode></entry>
<entry><errorname>Argument 6 to pop3_get must be a vector</errorname></entry>
<entry></entry>
</row>
<row>
<entry><errorcode>08006</errorcode></entry>
<entry><errorcode>PO014</errorcode></entry>
<entry><errorname>Misc. error in connection in pop3_get</errorname></entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
</refsect1>
<refsect1 id="examples_pop3_get"><title>Examples</title>
<example id="ex_pop3_get_3"><title>Get messages from remote POP3</title>
<para>This example retrieves messages from a remote POP3 server and stores them in a table.</para>
<screen>create table MY_MSGS (MSG_ID INTEGER IDENTITY,
MSG_HOST VARCHAR,
MSG_UIDL VARCHAR,
MSG_TEXT LONG VARCHAR,
primary key (MSG_ID, MSG_HOST, MSG_UIDL));
create procedure
get_msgs (in pop_host varchar, in pop_uid varchar, in pop_pwd varchar)
{
declare msg_vec any;
declare inx integer;
msg_vec := pop3_get (concat (pop_host, ':110'),
pop_uid,
pop_pwd,
10000000,
'delete');
inx := 0;
while (inx < length (msg_vec))
{
insert into MY_MSGS (MSG_HOST, MSG_UIDL, MSG_TEXT)
values (pop_host,
aref (aref (msg_vec, inx), 0),
aref (aref (msg_vec, inx), 1));
inx := inx + 1;
}
}
</screen>
<para>Here is a test run. Just for the fun, let's get the message subjects, too.</para>
<screen>
SQL> get_msgs('pop.xs4all.nl', 'ghard', '|_337h4x0R');
SQL> select MSG_UIDL, length (MSG_TEXT), get_keyword ('Subject', aref (mime_tree (MSG_TEXT), 0)) from MY_MSGS;
MSG_UIDL callret callret
VARCHAR NOT NULL INTEGER VARCHAR
_______________________________________________________________________________
1003930514.maildrop7.14798 3482 [Fwd: Linux Expo]
1003930555.maildrop7.15349 7683 [Fwd: SOAP options example]
2 Rows. -- 8 msec.
</screen>
</example>
</refsect1>
<refsect1 id="seealso"><title>See Also</title>
<para><link linkend="fn_mime_tree"><function>mime_tree</function></link>,
<ulink url="http://www.ietf.org/rfc/rfc1725">RFC1725</ulink></para>
</refsect1>
</refentry>
|