Retrieves or deletes e-mail messages from a POP mail server.
Communications tags, Internet protocol tags
<cfpop
server = "server name"
action = "getHeaderOnly|getAll|delete"
attachmentPath = "path"
debug = "yes|no">
generateUniqueFilenames = "yes|no"
maxRows = "number"
messageNumber = "number"
name = "query name"
password = "password"
port = "port number"
startRow = "number"
timeout = "seconds"
uid = "number"
username = "user name">
attributeCollection attribute
whose value is a structure. Specify the structure name in the attributeCollection attribute
and use the tag’s attribute names as structure keys.cfftp, cfhttp, cfldap, cfmail, cfmailparam, SetLocale; Sending and
Receiving E-Mail in the Developing ColdFusion Applications
ColdFusion MX 7.01: Added cids query variable.
ColdFusion MX 6.1:
Added support for multipart mail messages with Text and HTML parts.
Changed the attachment name separator: the TAB character
is now the separator between attachment names in the attachments and attachmentfiles query
fields if a message has multiple attachments. This behavior is identical
to ColdFusion 5 and earlier versions.
ColdFusion
MX: Changed the attachment name separator: the comma separates names
in the attachments and attachmentfiles query
fields if a message has multiple attachments.
Attribute |
Req/Opt |
Default |
Description |
|---|---|---|---|
|
Required |
POP server identifier:
|
|
|
Optional |
|
|
|
Optional |
If If you omit this attribute,
ColdFusion does not save any attachments. If you specify a relative
path, the path root is the ColdFusion temporary directory, which
is returned by the |
|
|
Optional |
|
|
|
Optional |
|
|
|
Optional |
Retrieves all available rows |
Number of messages to return or delete,
starting with the number in |
|
|
Message number or comma-separated list of message numbers to get or delete. Invalid message numbers are ignored. Ignored
if |
|
|
Required if |
Name for query object that contains the retrieved message information. |
|
|
Optional |
Password that corresponds to |
|
|
Optional |
110 |
POP port. |
|
Optional |
1 |
First row number to get or delete. Ignored
if |
|
Optional |
60 |
Maximum time, in seconds, to wait for mail processing. |
|
|
UID or a comma-separated list of UIDs to get or delete. Invalid UIDs are ignored. |
|
|
Optional |
A user name. |
The cfpop tag
retrieves one or more mail messages from a POP server and populates
a ColdFusion query object with the resulting messages, one message per
row. Alternatively, it deletes one or more messages from the POP
server.
cfpop tag
encounters malformed mail messages, it does not generate errors;
instead, it returns empty fields.To optimize performance, two retrieve options are available. Message header information is typically short, and therefore quick to transfer. Message text and attachments can be long, and therefore take longer to process.
Use the following syntax to specify an in-memory
directory in the attachmentpath attribute. In-memory
files speed processing of transient data.
ram:///path
The
path can include multiple directories, for example ram:///petStore/mail/attachments You
must create the directories in the path before you specify the file.
For more information on using in-memory files, see Optimizing
transient files in the Developing ColdFusion Applications.
The following table describes the
variables that provide information about the query that is returned
by cfpop:
Variable names |
Description |
|---|---|
queryname.recordCount |
Number of records returned by query. |
queryname.currentRow |
Current row that |
queryname.columnList |
List of column names in query. |
The following table lists
the message header and body columns that are returned if action =
"getHeaderOnly" or "getAll":
Column name |
getHeaderOnly returns |
getAll returns |
|---|---|---|
queryname.date |
|
|
queryname.from |
|
|
queryname.messagenumber |
|
|
queryname.messageid |
|
|
queryname.replyto |
|
|
queryname.subject |
|
|
queryname.cc |
|
|
queryname.to |
|
|
queryname.body |
|
|
queryname.textBody |
|
|
queryname.HTMLBody |
|
|
queryname.header |
|
|
queryname.attachments |
|
|
queryname.attachmentfiles |
|
|
queryname.UID |
|
|
queryname.cids |
|
|
If the mail message includes a part with a Content-Type of text/plain, the queryname.textBody column contains the part’s message content. If the mail message includes a part with a Content-Type of text/HTML, the queryname.HTMLBody column contains the part’s message content. If no Content-Type matches these types, the columns are empty. The queryname.Body column always contains the first message body found.
The queryname.attachments
column contains a tab-separated list of all the attachment names.
The queryname.attachmentfiles column contains a tab-separated list
of the locations of the attachment files. Use the cffile tag
to delete these temporary files when you have processed them.
To create a ColdFusion date/time object from the date-time string that is extracted from a mail message in the queryname.date column, use the following table:
Locale |
How to create a ColdFusion date/time object from queryname.date |
|---|---|
English (US) |
Use the |
Other |
Extract the date part of string; pass it
to the |
SetLocale function.For
more information on cfpop, see Sending
and Receiving E-Mail in the Developing ColdFusion Applications.
<!--- This view-only example shows the use of cfpop. --->
<h3>cfpop Example</h3>
<p>cfpop lets you retrieve and manipulate mail in a POP3 mailbox.
This view-only example shows how to create one feature of
a mail client, to display the mail headers in a POP3 mailbox.
<p>To execute this, un-comment this code and run with a mail-enabled CF Server.
<!---
<cfif IsDefined("form.server")>
<!--- Make sure server, username are not empty. --->
<cfif form.server is not "" and form.username is not "">
<cfpop server = "#form.popserver# " username = #form.username# password = #form.pwd#
action = "getHeaderOnly" name = "GetHeaders ">
<h3>Message Headers in Your Inbox</h3>
<p>Number of Records:
<cfoutput>#GetHeaders.recordCount#</cfoutput></p>
<ul>
<cfoutput query = "GetHeaders">
<li>Row: #currentRow#: From: #From# -- Subject: #Subject#
</cfoutput>
</ul>
</cfif>
</cfif>
<form action = "cfpop.cfm " method = "post">
<p>Enter your mail server:</p>
<p><input type = "Text" name = "popserver"></p>
<p>Enter your username:</p>
<p><input type = "Text" name = "username"></p>
<p>Enter your password:</p>
<p><input type = "password" name = "pwd"></p>
<p><input type = "Submit" name = "get message headers"></p>
</form>
--->