View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfpop PreviousNext

cfpop

Retrieves or deletes e-mail messages from a POP mail server.

Forms tags, Internet Protocol tags

<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 = "boolean">

cfftp, cfhttp, cfldap, cfmail, cfmailparam, SetLocale

ColdFusion MX 6.1:

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

server

Required

 

POP server identifier:

  • A host name; for example, "biff.upperlip.com"
  • An IP address; for example, "192.1.2.225"

port

Optional

110

POP port

username

Optional

 

A user name

password

Optional

 

Password that corresponds to username.

action

Optional

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.

message
Number

 

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

60

Maximum time, in seconds, to wait for mail processing.

maxRows

Optional

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

1

First row number to get or delete. Ignored if messageNumber or uid is specified,

generate
Unique
Filenames

Optional

No

  • Yes: Generate unique filenames for files attached to an e-mail message, to avoid naming conflicts when files are saved
  • No

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.

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:

Variable names

Description

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":

Column name

getHeaderOnly returns

getAll returns

queryname.date

yes

yes

queryname.from

yes

yes

queryname.messagenumber

yes

yes

queryname.replyto

yes

yes

queryname.subject

yes

yes

queryname.cc

yes

yes

queryname.to

yes

yes

queryname.body

not available

yes

queryname.textBody

not available

yes

queryname.HTMLBody

not available

yes

queryname.header

not available

yes

queryname.attachments

not available

yes

queryname.attachmentfiles

not available

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.attachments 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 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 Sending and Receiving E-Mail in Developing ColdFusion MX 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 = "#server# " username = #UserName# password = #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 = "server"> <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> --->

Contents > CFML Reference > ColdFusion Tags > cfpop PreviousNext

ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


brianatvfive said on Oct 18, 2003 at 12:10 PM :
This page has a typo that says qryname.attachments twice; qryname.attachments is the tab separated list of attachments and qryname.attachmentfiles is the list of filenames that you can process with CFFILE.
jrunrandy said on Nov 6, 2003 at 6:13 AM :
There is a big mistake and a little mistake in the example:
The big mistake is that "server" is a reserved word, starting in cfmx. So change the variable "server" to something like "popserver".
The little mistake is that the form variables in the first part of the example should all be prefixed with the form. prefix
No screen name said on May 21, 2004 at 4:17 AM :
When i recibed attachments with CFPOP and the file names have special characters, they are saved in my Linux Server with other characters, and then i can't access to them.

Is there any way to saved theese files with a determinate codification?

Thanks
Mettedraq said on Jun 14, 2004 at 10:20 AM :
I have one big problem.. and I haven't seen anyone ask about it yet..
I am able to save attachments from pop and readbinary the file and save it locally to cfmail the attachment of an email.. to basically forward the email..

problems..
1) I cannot get the ".msg" - outlook message file - to save as an attachment so I don't loose any attachments that it might have within itself. Which would be nice to just slam the text into the body and save the attachments.
2) There is no mention of this anywhere!!! WHY?!?!?!! shouldn't an attachment still be an attachment after receiving it through cfpop.

Please find any information on this and post it ASAP.. I am working on an email splitter in coldfusion to allow someone to work with fax images over a web site.. rather than through adobe acrobat and outlook..

let me know any info through this site.. thanx..

Mettedraq
jrunrandy said on Jun 14, 2004 at 12:48 PM :
Mettedraq, ColdFusion does not support what you are asking for.
Kerrdo said on Oct 13, 2004 at 6:45 PM :
Why dosen't cfpop support action="getUIDOnly"
Is this something that is to difficult to impliment?
Is there any chance of MM releasing an update for this?
jrunrandy said on Oct 13, 2004 at 7:12 PM :
I have added enhancement request 58141 into our bug database.
sweetnevil said on Oct 15, 2004 at 1:29 PM :
While I assume that in order to run CFPOP over TLS/SSL, all one would do is set port="995" in the CFPOP tag... however the documentation makes no mention whatsoever of CFPOP's SSL capabilities....

I see this as a fairly serious omission, since SSL and security are ever-more critical aspects of web development.

Any additions to this portion of the document would be superb!
Abinidi said on Dec 7, 2004 at 9:32 PM :
How do you get queryname.uid to show up even? Or is that part of the enhancement?

<cfpop action="getall" name="pics"
server="mail.myserver.com"
username="mypics@myserver.com"
password="password">
<cfoutput>total: #pics.recordCount#</cfoutput><br>
<cfoutput query="pics" >
#subject# - #htmleditformat(to)# - #messagenumber# - #pics.uid#<br>
</cfoutput>
I get a blank uid...
halL said on Dec 16, 2004 at 8:59 AM :
There is a bug in ColdFusion MX (fixed in the upcoming release) that the value returned in the UID field is not the messge UID, but the message ID.
I have tested your example code in ColdFusion MX 6.1 and I do get the message ID in the UID field.
bigzman said on Jun 6, 2005 at 10:39 AM :
The CFPOP tag seems to be handling incorrectly DNS resolution of round robin to more than one host. If the server attribute in the cfpop is set to a domain name pointing to more than one IP in the DNS, the CFPOP throws an exception javax.mail.MessagingException: Connect failed;coldfusion.mail.MailSessionException: An exception occurred when setting up mail server parameters(details below).

When the server is set to either any of the IP addresses from the round robin or the corresponding domain names with 1-to-1 mapping, CFPOP works fine. I have observed this exception on CFMX 6.1 in j2ee/jrun4 config under Linux RedHat AS 3. Seems to work fine under J2EE setup on Win XP Pro.

Any comemnts anyone?

--
An exception occurred when setting up mail server parameters.This exception was caused by: javax.mail.MessagingException: Connect failed; nested exception is: java.net.ConnectException: Connection refused. The specific sequence of files included or processed is: /www/pop.cfm "
coldfusion.mail.MailSessionException: An exception occurred when setting up mail server parameters.
at coldfusion.tagext.net.PopTag.doStartTag(PopTag.java:373)
at coldfusion.runtime.CfJspPage._emptyTag(CfJspPage.java:1876)
at cfpop2ecfm2126649301.runPage(/www/pop.cfm:12)
at coldfusion.runtime.CfJspPage.invoke(CfJspPage.java:147)
at coldfusion.tagext.lang.IncludeTag.doStartTag(IncludeTag.java:357)
at coldfusion.filter.CfincludeFilter.invoke(CfincludeFilter.java:62)
at coldfusion.filter.ApplicationFilter.invoke(ApplicationFilter.java:107)
at coldfusion.filter.RequestMonitorFilter.invoke(RequestMonitorFilter.java:48)
at coldfusion.filter.PathFilter.invoke(PathFilter.java:80)
at coldfusion.filter.ExceptionFilter.invoke(ExceptionFilter.java:47)
at coldfusion.filter.BrowserDebugFilter.invoke(BrowserDebugFilter.java:52)
at coldfusion.filter.ClientScopePersistenceFilter.invoke(ClientScopePersistenceFilter.java:28)
at coldfusion.filter.BrowserFilter.invoke(BrowserFilter.java:35)
at coldfusion.filter.GlobalsFilter.invoke(GlobalsFilter.java:43)
at coldfusion.filter.DatasourceFilter.invoke(DatasourceFilter.java:22)
at coldfusion.CfmServlet.service(CfmServlet.java:105)
at coldfusion.bootstrap.BootstrapServlet.service(BootstrapServlet.java:89)
at jrun.servlet.ServletInvoker.invoke(ServletInvoker.java:91)
at jrun.servlet.JRunInvokerChain.invokeNext(JRunInvokerChain.java:42)
at jrun.servlet.JRunRequestDispatcher.invoke(JRunRequestDispatcher.java:257)
at jrun.servlet.ServletEngineService.dispatch(ServletEngineService.java:541)
at jrun.servlet.jrpp.JRunProxyService.invokeRunnable(JRunProxyService.java:204)
at jrunx.scheduler.ThreadPool$ThreadThrottle.invokeRunnable(ThreadPool.java:426)
at jrunx.scheduler.WorkerThread.run(WorkerThread.java:66)
Hutz said on Aug 5, 2005 at 3:35 PM :
With field names like "Date" and "From", the query returned by CFPOP is not suitable at all for a query of a query, "Date" and especially "From" being SQL reserved words.

Image wanting to get only email messages dated within the last hour for an rss type application: should be easy enough, right?
<CFPOP name="popresult" etc etc>
<CFQUERY DBTYPE="query">
SELECT *
FROM popresult
WHERE DATE < #Now()-1/24#
</CFQUERY>
The SQL will crash on the word "Date" -- even though that's the name of the field, you can't use it...

Image wanting to scan subjects of emails only from some specific person:
<CFPOP name="popresult" etc etc>
<CFQUERY DBTYPE="query">
SELECT Subject, From
FROM popresult
WHERE From = 'specific person'
</CFQUERY>
What's poor SQL to make of all those "from"s? Which one is the SQL syntax one, and which one is the field name?

A little more care should have gone into naming the returned fields; something like POPDate and POPFrom maybe....
hlevin said on Sep 7, 2005 at 1:25 PM :
It appears that the old bug from CF4.5 is still present in CFMX6.1. cfpop does not see rfc822 embedded messages. While outlook sees the rfc822 content as an attachment, CFPOP ignores that part alltogether. Wonder if there is a workaround or a some hidden variable which can display the entire raw content of the email message with all headers and message boundaries.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b14.htm