Receiving Email Messages (CFPOP)  
 
 

CFPOP, the Post Office Protocol tag, expands the ColdFusion developer's ability to add Internet mail client features and email consolidation to applications. While a conventional mail client provides an adequate interface for personal mail, there are many cases where an alternative interface to some mailboxes is desirable. CFPOP is a tool to develop targeted mail clients to suit the specific needs of a wide range of applications.

Use CFPOP in applications when you want to receive email. Here are two instances where implementing POP mail makes sense:

  • If your site has generic mailboxes that are read by more than one person (sales@yourcompany.com), it may be more efficient to construct a ColdFusion mail front-end to supplement individual user mail clients.
  • In many applications, the processing of mail can be automated when the mail is formatted to serve a particular purpose. For example, when subscribing to a list server.

Use the CFPOP tool in the CFML Advanced toolbar in ColdFusion Studio to add CFPOP tags to your pages.

See the CFML Language Reference for more information on CFPOP syntax and variables.

 
 
  CFPOP Example  
 

This example shows the basic syntax of CFPOP:

<CFPOP SERVER="my.mailserver.com"
    USERNAME=#username#
    PASSWORD=#pwd#
    ACTION="GetHeaderOnly"
    NAME="getmsghdrs">

<BODY>
<CFOUTPUT>
You have #getmsghdrs.RecordCount# messages to read.
</CFOUTPUT>

<CFOUTPUT QUERY="getmsghdrs">
    <P><B>Date: </B>#getmsghdrs.date#</P>
    <P><B>From: </B>#getmsghdrs.from#</P>
</CFOUTPUT>
</BODY>
 
 
  Using CFPOP  
 
     
 
  To implement the CFPOP tag in your ColdFusion application:  
 
  1. Choose which mail boxes you want to access within your ColdFusion application.
  2. Determine what mail message components you need to process: message header, message body, attachments, etc.
  3. Decide if you need to store the retrieved messages in a database.
  4. Decide if you need to delete messages from the POP server once you've retrieved them.
  5. Incorporate the CFPOP tag in your application and create a user interface for accessing a given mailbox.
  6. Build an application page to handle the output. Retrieved messages can include ASCII characters that do not display properly in the browser.

    Use the CFOUTPUT tag with the HTMLCodeFormat and HTMLEditFormat functions to control output to the browser. Note the use of these functions in the examples.

 
 
  CFPOP query variables  
 
 

Two variables are returned for each CFPOP query that provide record number information:

  • RecordCount: The total number of records returned by the query.
  • CurrentRow: The current row of the query being processed by CFOUTPUT in a query-driven loop.

You can reference these properties in a CFOUTPUT tag by prefixing the query variable with the query name in the NAME attribute of CFPOP:

<CFOUTPUT>
This operation returned #Sample.RecordCount# messages.
</CFOUTPUT>


 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.