<cfimap>

Retrieves and deletes email messages from an IMAP email server.

This tag works exactly the same way as the <cfpop> tag. It has the same attributes.

The Internet Message Access Protocol or IMAP is one of two of the most prevalent Internet standard protocols for email retrieval, the other being POP3. Virtually all modern email clients and servers support both protocols as a means of transferring email messages from a server, such as those used by Gmail, or to a client such as Mozilla Thunderbird and Microsoft Outlook.

Many implementations of webmail use IMAP to retrieve email messages from a server and display them within a web browser, making the use of this protocol transparent to the user.

This tag cannot have a body.

This tag is also supported within <cfscript>

<cfimap connection=string server=string port=number uid=string username=string password=string secure=boolean action=getHeaderOnly|getAll|delete|open|close|markRead|createFolder|deleteFolder|renameFolder|listAllFolders|moveMail name=string messagenumber=string attachmentpath=string timeout=number maxrows=number startrow=number debug=boolean generateuniquefilenames=boolean folder=string newfolder=string recurse=boolean delimiter=string >
Attribute Description Default
connection
string, optional

label for a connection.

server
string, optional

Host name biff.upperlip.com or IP address 192.1.2.225 of the Imap server.

port
number, optional

Defaults to the standard Imap port, 143.

uid
string, optional

Specifies the unique ID or a comma-delimited list of Uids to retrieve or delete. If you set invalid Uids, then they are ignored.

username
string, optional

If no user name is specified, the Imap connection is anonymous.

password
string, optional

Password that corresponds to user name.

secure
boolean, optional

enables SSL for pop requests

action
string, optional

Specifies the IMAP action to perform.

  • getHeaderOnly
  • getAll
  • delete
  • open
  • close
  • markread
  • createfolder
  • deletefolder
  • renamefolder
  • listallfolders
  • movemail

getHeaderOnly

name
string, optional

Name for the index query.

Alias: variable

messagenumber
string, optional

Can be a comma-separated list of the message ids

attachmentpath
string, optional

Allows attachments to be written to the specified directory when action = "getAll". If an invalid attachmentPath is specified, no attachment files are written to the server.

timeout
number, optional

Specifies the maximum time, in seconds, to wait for mail processing. Defaults is 60 seconds.

maxrows
number, optional

Sets the number of messages returned, starting with the number in the startRow attribute.

This attribute is ignored if messageNumber is specified.

startrow
number, optional

Specifies the first row number to be retrieved. Default is 1. This attribute is ignored if messageNumber is specified.

generateuniquefilenames
boolean, optional

Boolean indicating whether to generate unique filenames for the files attached to an e-mail message to avoid naming conflicts when the files are saved. Default is NO.

folder
string, optional
newfolder
string, optional
recurse
boolean, optional
delimiter
string, optional

Character that separates uid list, The default value is comma(,).

Alias: delimiters

Unimplemented Attribute(s)

Attribute Description Default
debug
boolean, optional

this attribute is deprecated and ignored, log control happens via the logging framework directly.

* deprecated *

Examples

Action getAll

<cfimap
	action="getAll"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#"
	name="getAll" maxrows ="10" attachmentpath="#expandpath('./')#" generateuniquefilenames="true">
<cfdump var="#getAll#" />

Action getHeaderOnly

<cfimap
	action="getHeaderOnly"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#"
	name="getHeader" maxrows ="10">
<cfdump var="#getHeader#" />

Action CreateFolder

<cfimap
	action="CreateFolder"
	folder="NewFolderFromIMAP_Test"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#"
	name="CreateFolder">

Action ListAllFolders

<cfimap
	action="ListAllFolders"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#"
	name="ListAllFolders" maxrows ="10">
<cfdump var="#ListAllFolders#" />

Action renamefolder

<cfimap
	action="renamefolder"
	folder="NewFolderFromIMAP_Test"
	newFolder="RenameFolderFromIMAP"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#">

Action deletefolder

<cfimap
	action="deletefolder"
	folder="NewFolderFromIMAP_Test"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#"
	maxrows ="10">

Action MoveMail

<cfimap
	action="MoveMail"
	Newfolder="newfolder"
	messagenumber ="1"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#">

Action MarkRead

<cfimap
	action="MarkRead"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#">

Action open

<cfimap
	action="open"
	connection="openConnc"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#">

Action close

<cfimap action="close" connection="openConnc">

Action Delete

<cfimap
	action="delete"
	folder=""
	messagenumber ="1"
	server="#Imap.Server#"
	port="#Imap.Port#"
	username="#Imap.Username#"
	password="#Imap.Password#"
	secure="#Imap.Secure#">

See also