Solved

receive email using cfmail

Posted on 2003-11-06
6
411 Views
Last Modified: 2013-12-24
is it possible to receive email using cfmail. if not, is it something else? cfftp?  i want to be able to check email using a browser window.
0
Comment
Question by:phillystyle123
6 Comments
 
LVL 10

Expert Comment

by:Mause
ID: 9693451
well almost its cfpop

to get only the headers
<cfpop action="GETHEADERONLY" name="allheaders" server="#server#">

<cfoutput query = "allheaders">
From: #From# - Subject: #Subject#
</cfoutput>

use getAll  in the action to get the rest of the mail

Mause
0
 
LVL 17

Accepted Solution

by:
anandkp earned 50 total points
ID: 9699049
Hi,
yes CFPOP is teh answere ... heres a example of what i had written when i first tried it :)

<CFPOP SERVER="#MAILSEVER_IP#" USERNAME="anand" PASSWORD="anand" ACTION="GetAll" NAME="getmail" GENERATEUNIQUEFILENAMES="YES">

<TABLE WIDTH="98%" ALIGN="center" CELLPADDING="0" CELLSPACING="0" BORDER="0">
      <TR BGCOLOR="000099">
            <TD BGCOLOR="000099" WIDTH="100%">      
                  <TABLE WIDTH="100%" ALIGN="center" CELLPADDING="3" CELLSPACING="1" BORDER="0">
                        <TR BGCOLOR="000099">
                              <TD WIDTH="19%"><FONT FACE="Verdana" SIZE="2" COLOR="ffffCC"><B>Total eMails</B></FONT></TD>
                              <TD WIDTH="1%"><FONT FACE="Verdana" SIZE="2" COLOR="ffffCC"><B>:</B></FONT></TD>
                              <TD WIDTH="80%" COLSPAN="4"><FONT FACE="Verdana" SIZE="2" COLOR="ffffCC"><B><CFOUTPUT>#getmail.RecordCount#</CFOUTPUT></B></FONT></TD>
                        </TR>
                        <CFOUTPUT QUERY="getmail">      
                              <TR BGCOLOR="FFFFFF">                  
                                    <TD COLSPAN="6" BGCOLOR="e9e9e9"><FONT FACE="Verdana" SIZE="2">&nbsp;</FONT></TD>
                              </TR>
                              <TR BGCOLOR="FFFFFF">
                                    <TD WIDTH="19%"><FONT FACE="Verdana" SIZE="2">Number</FONT></TD>
                                    <TD WIDTH="1%"><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD WIDTH="30%"><FONT FACE="Verdana" SIZE="2">#getmail.messagenumber#</FONT></TD>                  
                                    <TD WIDTH="19%"><FONT FACE="Verdana" SIZE="2">Date</FONT></TD>
                                    <TD WIDTH="1%"><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD WIDTH="30%"><FONT FACE="Verdana" SIZE="2">#getmail.date#</FONT></TD>
                              </TR>
                              <TR BGCOLOR="FFFFFF">
                                    <TD><FONT FACE="Verdana" SIZE="2">From</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">&nbsp;#getmail.from#&nbsp;</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">Reply To</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">&nbsp;#getmail.replyto#&nbsp;</FONT></TD>
                              </TR>
                              <TR BGCOLOR="FFFFFF">
                                    <TD><FONT FACE="Verdana" SIZE="2">To</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">&nbsp;#getmail.to#&nbsp;</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">CC</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">&nbsp;#getmail.cc#&nbsp;</FONT></TD>
                              </TR>
                              <TR BGCOLOR="FFFFFF">
                                    <TD><FONT FACE="Verdana" SIZE="2">Subject</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD COLSPAN="4"><FONT FACE="Verdana" SIZE="2">&nbsp;#getmail.subject#&nbsp;</FONT></TD>
                              </TR>
                              <TR BGCOLOR="FFFFFF">
                                    <TD><FONT FACE="Verdana" SIZE="2">Message</FONT></TD>
                                    <TD><FONT FACE="Verdana" SIZE="2">:</FONT></TD>
                                    <TD COLSPAN="4"><FONT FACE="Verdana" SIZE="2">&nbsp;#getmail.body#&nbsp;</FONT></TD>
                              </TR>            
                        </CFOUTPUT>                        
                  </TABLE>
            </TD>
      </TR>
</TABLE>

run this page with ur server_ip & mail settings !

HTH

K'Rgds
Anand
0
 
LVL 10

Expert Comment

by:substand
ID: 9699366
you'll need to use cfpop... here are the docs on it:



CFPOP
CFPOP retrieves and deletes email messages from a POP mail server. See also CFMAIL.

Syntax
<CFPOP SERVER="servername"
    PORT="port_number"
    USERNAME="username"
    PASSWORD="password"
    ACTION="action"
    NAME="queryname"
    MESSAGENUMBER="number"
    ATTACHMENTPATH="path"
    TIMEOUT="seconds"
    MAXROWS="number"
    STARTROW="number"
    GENERATEUNIQUEFILENAMES="boolean">

SERVER
Required. Host name (biff.upperlip.com) or IP address (192.1.2.225) of the POP server.

PORT
Optional. Defaults to the standard POP port, 110.

USERNAME
Optional. If no user name is specified, the POP connection is anonymous.

PASSWORD
Optional. Password corresponds to user name.

ACTION
Optional. Specifies the mail action. There are three possible values:

GetHeaderOnly -- (Default) Returns message header information only.
GetAll -- Returns message header information, message text, and attachments if ATTACHMENTPATH is specified.
Delete -- Deletes messages on the POP server.
Note  Two retrieve options are offered to maximize performance. Message header information is typically short and therefore quick to transfer. Message text and attachments can be very long and therefore take longer to process. See the Message Header and Body Columns table, which follows the CFPOP attribute descriptions, for information on retrieving header and body information form the query when you specify GetHeaderOnly or GetAll.  



NAME
Optional. The name you assign to the index query. Required for ACTION="GetHeaderOnly" and ACTION="GetAll".

MESSAGENUMBER
Optional. Specifies the message number(s) for the given action. MESSAGENUMBER is required for ACTION="Delete". If it is provided for ACTION="GetHeaderOnly" or ACTION="GetAll", only referenced messages will be retrieved. If it is omitted for ACTION="GetHeaderOnly"or ACTION="GetAll", all messages available on the server are returned.

MESSAGENUMBER can contain individual message numbers or a comma-separated list of message numbers. Invalid message numbers will be ignored.

ATTACHMENTPATH
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
Optional. Specifies the maximum amount of time in seconds to wait for mail processing. Defaults to 60 seconds.

MAXROWS
Optional. Specifies the maximum number of entries for mail queries. This attribute is ignored if MESSAGENUMBER is specified.

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

GENERATEUNIQUFILENAMES
Optional. Boolean indicating whether to generate unique file names for the files attached to an email message in order to avoid naming conflicts when the files are saved. The default is NO.

CFPOP Query Variables
The following table describes the query variables that are returned by CFPOP. The example illustrates their use.

 CFPOP Query Variables  
Variable Names  Description  
queryname.RecordCount

 The total number of records returned by the query.  
queryname.CurrentRow

 The current row of the query being processed by CFOUTPUT.  
queryname.ColumnList

 The list of the column names in the query.  


Message Header and Body Columns
The following table lists the message header and body columns that are returned by CFPOP when you specify the ACTION attribute to be either GetHeaderOnly or GetAll. All of the columns are returned if you specify GetAll, but only header information is returned when you specify GetHeaderOnly.

 Message Header and Body Columns  
Column Name  GetHeaderOnly returns  GetAll returns  
queryname.date

 yes  yes  
queryname.from

 yes  yes  
queryname.messagenumber

 yes  yes  
queryname.replyto

 yes  yes  
queryname.subject

 yes  yes  
queryname.cc

 yes  yes  
queryname.to

 yes  yes  
queryname.body

 not available  yes  
queryname.header

 not available  yes  
queryname.attachments

 not available  yes  
queryname.attachmentfiles

 not available  yes  


Usage
To create a ColdFusion date/time object from the date-time string that is extracted from a mail message in the queryname.date column, use the following table to determine what to do.

 Date-Time Parsing According to Locale  
Locale  What to do?  
English (US) locale

 Use the ParseDateTime function and specify the POP attribute, which converts the date-time value to Greenwich Meantime.  
Other locales

 Extract the date portion of the string and pass it to the LSParseDateTime function, then add or subtract the conversion time, depending on the locale.  


See also the description of the SetLocale function.

For complete usage information on CFPOP, see Developing Web Applications with ColdFusion.

Example
<!--- This view-only example shows the use of CFPOP --->
<HTML>
<HEAD>
<TITLE>CFPOP Example</TITLE>
</HEAD>

<BODY>
<H3>CFPOP Example</H3>
<P>CFPOP allows you to retrieve and manipulate mail
in a POP3 mailbox.  This view-only example shows how to
create one feature of a mail client, allowing you to display
the mail headers in a POP3 mailbox.

<P>Simply uncomment this code and run with a mail-enabled CF Server to
see this feature in action.
<!---
<CFIF IsDefined("form.server ")>
<!--- make sure server, username are not empty --->
<CFIF form.server is not "" and form.username is not "">
     <CFPOP SERVER= "#server# " USERNAME=#UserName# PASSWORD=#pwd#
     ACTION= "GETHEADERONLY " NAME= "GetHeaders ">
     
     <H3>Message Headers in Your Inbox</H3>
     <P>Number of Records:
     <CFOUTPUT>#GetHeaders.RecordCount#</CFOUTPUT></P>
     <UL>
     <CFOUTPUT QUERY="GetHeaders">
         <LI>Row: #CurrentRow#:  From: #From# -- Subject: #Subject#
     </CFOUTPUT>
    </UL>
</CFIF>
</CFIF>

<FORM ACTION= "cfpop.cfm " METHOD= "POST ">
<P>Enter your mail server:
<P><INPUT TYPE= "Text " NAME= "server ">
<P>Enter your username:
<P><INPUT TYPE= "Text " NAME= "username ">
<P>Enter your password:
<P><INPUT TYPE= "password " NAME= "pwd ">
<INPUT TYPE= "Submit " NAME= "get message headers ">
</FORM>
--->

</BODY>
</HTML>      

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:phillystyle123
ID: 9704183
anandkp - ok that works but how do i then use it to respond to emai?  do i use cfmail somehow????
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9713887
Use CFPOP to read thru ur mails on a POP server
& in case u wanna reply/forward them ... build ur own customised application using CFMAIL ...

I hope u r familiar with CFMAIL tag - if not let us know abt it !

K'Rgds
Anand
0
 
LVL 1

Expert Comment

by:fixx17
ID: 9912469
Referring back to your first querstion.
"is it possible to receive email using cfmail. "

You can recieve mail with CFMAIL.

Just add yourself to the CC list in CFMAIL or the BCC list.

For instance

<cfmail to="form.emailbox" replyto="emailaddy@youremail.com" from="Whatever Name you want to add here." subject="add a subject here." bcc="youremail@addy.com"></cfmail>


Pending on how your CFADMIN is set up, you can add which SMTP server it gets sent out to.  In the Cfmail tags, just add
SERVER="smtp.yourisp.net"  or whatever it is.

IF you dont have one,  your CFADMINISTRATOR will send it to the deafault SMTP server.


0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now