CFPOP |
Description Retrieves or deletes e-mail messages from a POP mail server.
Category Internet Protocol tags
Syntax
    <cfpop
       server = "servername"
       port = "port_number"
       username = "username"
       password = "password"
       action = "action"
       name = "queryname"
       messageNumber = "number"
       uid = "number"
       attachmentPath = "path"
       timeout = "seconds"
       maxRows = "number"
       startRow = "number"
       generateUniqueFilenames = "yes" or "no"
       debug = "yes" or "no">
See also cfftp, cfhttp, cfldap, cfmail, cfmailparam, SetLocale; Chapter 39, "Sending and Receiving E-Mail" in ColdFusion MX Developer's Guide.
History 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.
Usage 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.
Note: | When the 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 very long, and therefore take longer to process.
cfpop query variables The following table describes the variables that provide information about the query that is returned by cfpop:
queryname.recordCount | Number of records returned by query
queryname.currentRow | Current row that cfoutput is processing
queryname.columnList | List of column names in query
queryname.UID | Unique identifier for the e-mail message file
Query message header and body columns The following table lists the message header and body columns that are returned if action = "getHeaderOnly" or "getAll":
queryname.date | yes | yes
queryname.from | yes | yes
queryname.messagenumber | yes | yes
queryname.messageid | yes | yes
queryname.replyto | yes | yes
queryname.subject | yes | yes
queryname.cc | yes | yes
queryname.to | yes | yes
queryname.body | no | yes
queryname.textBody | no | yes
queryname.HTMLBody | no | yes
queryname.header | yes | yes
queryname.attachments | no | yes
queryname.attachmentfiles | no | yes
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:
English (US) | Use the ParseDateTime function. If you specify the pop-conversion attribute, the function adjusts the date/time object to UTC.
Other | Extract the date part of string; pass it to the LSParseDateTime function.
Note: | To set the default display format of date, time, number, and currency values, use the SetLocale function.
For more information on cfpop, see Chapter 39, "Sending and Receiving E-Mail" in ColdFusion MX Developer's Guide.
Example
    <!--- 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><input type = "Text" name = "popserver">
       <p>Enter your username:
       <p><input type = "Text" name = "username">
       <p>Enter your password:
       <p><input type = "password" name = "pwd">
       <input type = "Submit" name = "get message headers">
    </form>
    --->

SERVER |
| Required
POP server identifier: A host name; for example, "biff.upperlip.com". An IP address; for example, "192.1.2.225".

PORT |
| Optional
Default value: "110" POP port.

USERNAME |
| Optional
A user name.

PASSWORD |
| Optional
Password that corresponds to username.

ACTION |
| Optional
Default value: "getHeaderOnly" getHeaderOnly: returns message header information only getAll: returns message header information, message text, and attachments if attachmentPath is specified delete: deletes messages on POP server

NAME |
| Required if action = "getAll" or "getHeaderOnly"
Name for query object that contains the retrieved message information.

MESSAGENUMBER |
Message number or comma-delimited list of message numbers to get or delete. Invalid message numbers are ignored. Ignored if uid is specified.

UID |
UID or a comma-delimited list of UIDs to get or delete. Invalid UIDs are ignored.

ATTACHMENTPATH |
| Optional
If action="getAll", specifies a directory in which to save any attachments. If the directory does not exist, ColdFusion creates it. 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 GetTempDirectory function.

TIMEOUT |
| Optional
Default value: "60" Maximum time, in seconds, to wait for mail processing.

MAXROWS |
| Optional
Default value: "retrieves all available rows" Number of messages to return or delete, starting with the number in startRow. Ignored if messageNumber or uid is specified.

STARTROW |
| Optional
Default value: "1" First row number to get or delete. Ignored if messageNumber or uid is specified.

GENERATEUNIQUEFILENAMES |
| Optional
Default value: "No" Yes: generate unique filenames for files attached to an e-mail message, to avoid naming conflicts when files are saved. No

DEBUG |
| Optional
Default value: "No" Yes: sends debugging output to standard output. By default, if the console window is unavailable on server configurations, ColdFusion sends output to cf_root/runtime/logs/coldfusion-out.log. On J2EE configurations, with JRun, the default location is jrun_home/logs/servername-out.log. Caution: If you set this option to Yes, ColdFusion MX writes detailed debugging information to the log, including all retrieved message contents, and can generate large logs quickly. No: does not generate debugging output.