Question

I am developing a basic yet highly customized CRM for a small training centre which has the ability to store student records and also send emails to them. I'm using SwiftMailer following this excellent tutorial in CakePHP to accomplish the sending part.

Of course, students are sometimes going to reply to emails and I'd like to retrieve them within my CRM and store them along with the student record.

However, I cannot find a single reference to doing this. I've tried the following Google searches: "receiving email cakephp" , "retrieving email cakephp" and even "email client cakephp" but all of these queries give results relating to sending mail rather than receiving it -- very frustrating!

Finally, I broadened my search to non-cake solutions and found someone recommending a library called ezComponents. It doesn't seem to have had any active development for about a year, but it includes an email receiving class which is exactly what I want. Unfortunately, I have no idea how to add this to CakePHP and the only post I've been able to find on the entire web on the matter doesn't exactly go into much detail. It's certainly not a step-by-step tutorial on using ezComponents on CakePHP like the SwiftMailer tutorial I mentioned above.

I also found a class on Google Code called php-imap which looks like it would do the job but, again, I haven't the slightest clue how to get it working happily in Cake like SwiftMailer is.

I realize that I may have to learn how to package classes for use in Cake by myself but I'm asking this question first on the off-chance that there is already a Cake-friendly solution to this problem that I just haven't realized :-)

Joseph

Was it helpful?

Solution

Thanks to everyone for your answers, but I've been doing some more searching and it looks like the solution is actually incredibly simple.

Basically, with the help of a plugin, I can set up the mail server in databases.php as a datasource and then write a Model and Controller to interact with it.

Here's the example I found: https://github.com/kvz/cakephp-emails-plugin

Edit: the repo has been deprecated and is now available at https://github.com/kvz/deprecated/tree/cakephp-emails-plugin

OTHER TIPS

You will want to pipe your email to PHP and use stdin:// to read the contents of the email and add the e-mail to your database.

I've done this with cake and the simplest way is to make a Cake console application to handle the parsing. Also using cpanel's account level filtering to generate the pipe is really simple.

http://forums.cpanel.net/f5/piping-mail-php-scripts-howto-checklist-50985.html

http://www.evolt.org/incoming_mail_and_php

Sounds like you want to include SwiftMailer as a Cake plugin, amirite?

http://book.cakephp.org/view/1111/Plugins

-- if you want to package it yourself. Otherwise, a cursory search of the Bakery yielded this result:

http://bakery.cakephp.org/articles/sky_l3ppard/2009/11/07/updated-swiftmailer-4-xx-component-with-attachments-and-plugins

Hopefully it will at least get you pointed in the right direction. HTH. :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top