Email Module and You

This tutorial will show you how to create an email module that will
display to you how many emails you have in your inbox of any pop 3 account.

First we will create a database so that you can store multiple user info.


I will be using mysql for this example.

CREATE TABLE 'tbl_email_users' 
(
    'fld_emailid' bigint(20) NOT NULL auto_increment,
    'fld_pop' varchar(255) default NULL,
    'fld_emailuname' varchar(255) default NULL,
    'fld_emailpass' varchar(255) default NULL,
    'fld_emailactivate' varchar(4) default NULL,
    PRIMARY KEY ('fld_emailid'),
    KEY 'fld_userid' ('fld_emailid')
) TYPE=MyISAM

Now that we have our table made lets start by creating application.cfm

<cfquery datasource="#dsn#" name="emailinfo_query">
   
SELECT *
    FROM tbl_email_users
</cfquery>

Now lets set some vars inside the application.cfm page

<cfset emailinfo = emailinfo_query>

<cfparam name=
"popServer" default="#emailinfo.fld_pop#">
<cfparam name=
"popUsername" default="#emailinfo.fld_emailuname#">
<cfparam name=
"popPassword" default="#emailinfo.fld_emailpass#">

This query can become more complex as you incorporate it into your system.
But for this tutorial we will just act like there is only one user.

Now lets create the emailDisplay.cfm page.

<cfif emailinfo.fld_emailactivate is "Yes">

    <cfpop action=
"GETHEADERONLY"
                server=
"#popServer#"
                name=
"qGetMessages"
                username=
"#popUsername#"
                password=
"#popPassword#">

    <cfoutput>
    <table width="150" cellpadding="5" border="0" cellspacing="0">
        <tr>
            <td align=
"center"><b>Email</b></td>
        </tr>
        <tr>
            <td align=
"center"> You have<br>
                #qGetMessages.RecordCount#<br>
                Email (s) <br>
                <a href="index.cfm?sector=email&page=inbox">Read Email</a> 
            </td>
        </tr>
    </table>

    </cfoutput>
</cfif>

This is all there is to making your very own display module for your website.

Remember this is a very simple system. It can become very robust depending on 
how you setup your table structure.



All ColdFusion Tutorials By Author: Jeremy Rottman
  • Coldfusion Powered Flex
    So as I am sure you are aware, Flex 2 hit the ground running recently. Have you been kicking yourself for not getting a head start on learning? Well for all the people who thought it was just a fad, this tutorial is here to save the day. I hope by reading and working through this tutorial you will get a general but firm understanding of simple to advanced workings of Flex.
    Author: Jeremy Rottman
    Views: 18,879
    Posted Date: Thursday, August 31, 2006
  • Email Module and You
    A simple email module tutorial that anyone can use and expand on.
    Author: Jeremy Rottman
    Views: 22,826
    Posted Date: Tuesday, March 15, 2005
  • Installing coldfusion with apache
    This tutorial will explain in detial how to install coldfusion mx 6.1 on a linux server, apache 2, and shows you how to make them work together.
    Author: Jeremy Rottman
    Views: 13,098
    Posted Date: Monday, March 21, 2005