Skip to main content
September 8, 2010
Question

Talk to the CF Server with email

  • September 8, 2010
  • 2 replies
  • 1317 views

I have a client who wants to be able to send an email to a generic address like kickoff@mydomain.com and have that trigger a .cfm page.

I have no idea if this is possible or not but I'm assuming it would be something like Facebook's reply to comment via email feature where a user replies to an automatic email and then when the reply is recieved by the server it runs an insert statement.

Can someone help me understand how to approach this?

High level solution...

Step 1: User sends email to generic email address

Step 2: Server interprets request and kicks off cfm page

Step 3: cfm page runs as expected

This topic has been closed for replies.

2 replies

Inspiring
September 8, 2010

Yes this can be done, sort of.  It cannot actually "trigger" an immediate action on ColdFusion's part, but you can have a scheduled CF task that runs on a regular basis (every 5 minutes, etc), to check the inbox.  I received hundreds of emails per day containing data files from customers, and process them all with a CF task that periodically checks each of the inboxes for new mail.

Depending on the mail service you are dealing with, you have <CFPOP>, <CFEXCHANGE> (CF 8+), or <CFIMAP> (CF 9) to work with.

One of the tricky things is marking the messages you process so that you don't keep processing the same messages over and over.  I have found that with CFEXCHANGE I can use the isRead flag to do this.  I have an older script that uses an IMAP CFC that was available at the time, and with it I need to use the "deleted" flag for a message to mark that I've seen it.

You can use both the IMAP and EXCHANGE tags to work with MS Exchange servers, but if you use the IMAP tag then you need to be sure that the mailbox is setup for IMAP access.  If you use the EXCHANGE tag then you need to be sure that the mailbox is setup for OWE access.

Hope this helps,

-reed

September 9, 2010

I've done some searching on google and yahoo to try to find examples of how to specifically check the inbox ("Depending on the mail service you are dealing with, you have <CFPOP>, <CFEXCHANGE> (CF 8+), or <CFIMAP> (CF 9) to work with.") but haven't found anything useful.

Can you please show me some pseudo code using cfpop let's say on how to check the inbox and then flag messages?

Thank you!!

Inspiring
September 9, 2010

Take a look at the CF documentation. It includes sample code for checking a mail box with CFPOP.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec14b97-7feb.html

What do you mean by "flag messages"?

Inspiring
September 8, 2010

You could use CFSCHEDULE to create a task that regularly checks an email box using CFPOP and performs some action based on the content of the mail message(s) in the mail box.