Retrieving Messages

You have seen that ColdFusion can send email via the cfmail tag. In addition to sending email, ColdFusion can also retrieve email messages using the Post Office Protocol (POP3) via the cfpop tag. Using this tag, ColdFusion can retrieve message headers, message contents including multi-part messages (this is new in ColdFusion MX 6.1), and file attachments. In essence, this allows you to use ColdFusion to create a web-based email system, like Yahoo! Mail or Hotmail. The cfpop tag can also create applications such as auto-responders and mailing-list managers.

Retrieving Message Headers

The cfpop tag can retrieve just the header portion of email messages stored on a POP server. This is useful when you want to retrieve summary information such as the message title for more than one message. Retrieving just the message headers allows you to avoid the overhead associated with retrieving the entire contents of each message you retrieve. In the context of a web-based email client, this technique is used to build a list of messages in a user’s mailbox. You can retrieve the headers for a group of messages by setting the action attribute of the cfpop tag to GetHeaderOnly as shown in Example 13-8.

Example 13-8. Retrieving message headers

<cfpop action="getheaderonly" name="GetMessageHeaders" server="wcpamh01.amkor.com" port="110" timeout="600" username="rbils" password="leb##sggy" startrow="1" maxrows="100"> <html> <head> <title>Example 13-8: Retrieving Message Headers</title> ...

Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.