Coldfusion Mail Inbox Script Using cfpop

This script will show you how to read emails from a mail server, this script could be used for a web mail client.

First of all we need to create a connection to the mail server using the cfpop tag

<cfpop action="GETHEADERONLY"
server="#ServerName#"
name="GetMessages"
username="#Username#"
password="#Password#">

Now we have created the connection to the server and got the messages we can go about outputting them. This method is that same as you would with any query.

<cfif qGetMessages.RecordCount>
<table width="100%" border="0" cellpadding="2" cellspacing="1">
<tr>
<td width="100%" colspan="3" bgcolor="#000080">
<font size="2" face="Verdana" color="white"><strong>My Inbox</strong></font>
</td>
</tr>
<tr bgcolor="#efefef">
<td width="10%"><font size="2" face="Verdana"><strong>ID</strong></font></td>
<td width="40%"><font size="2" face="Verdana"><strong>FROM</strong></font></td>
<td width="50%"><font size="2" face="Verdana"><strong>SUBJECT</strong></font></td>
</tr>
<cfoutput query="GetMessages">
<tr>
<td><font size="2" face="Verdana">#GetMessages.Currentrow#</font></td>
<td><font size="2" face="Verdana">#GetMessages.from#</font></td>
<td><font size="2" face="Verdana">#GetMessages.subject#</font></td>
</tr>
</cfoutput>
</table>
<cfelse>
<font size="2" face="Verdana">Your inbox is empty</font>
</cfif>

So there we have a very simple script to display the contents of your inbox. I will soon be writing a script to show the email itself.

Enjoy

Related Blog Entries

Comments

Archives By Subject

Advertising (4) [RSS]
Blog Design (1) [RSS]
CFProject Scripts (2) [RSS]
Coldfusion Charts (3) [RSS]
Coldfusion Functions (5) [RSS]
Coldfusion Overview (1) [RSS]
Coldfusion Tutorials (17) [RSS]
For Sale (2) [RSS]
Image Manipulation (1) [RSS]
Java (1) [RSS]
JavaScript (4) [RSS]
PHP (1) [RSS]
Railo (2) [RSS]
SQL (1) [RSS]
Useful Tools (3) [RSS]

Recent Comments

Hashing Passwords
Richard Lord said: You really need to salt the passwords before hashing them, otherwise you're exposed to a rainbow-tab... [More]

Using Railo and Resin with domain aliases
Jonny Shaw said: Thanks for that. I am already using <host regexp="(.+)"> <host-name>${ho... [More]

Using Railo and Resin with domain aliases
Gert Franz said: Hi Jonny, it's even easier if you do it this way: <host id="allmead.com" root-dir... [More]

BlogCFC on Railo
Jonny Shaw said: Thanks for the advice ray. I was surprised at how easily BlogCFC went accross to to railo. The onl... [More]

BlogCFC on Railo
Gert Franz said: Congratulations to your new websites. I just wanted to add two things: CFIMAGE and CFCHART are suppo... [More]

Recent Entries

No recent entries.
ColdFusion Blog | ColdFusion Hosting | ColdFusion Q & A