Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Receiving / retrieving email in CakePHP

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

like image 691
Joseph Avatar asked Jun 12 '11 03:06

Joseph


1 Answers

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

like image 187
Joseph Avatar answered Sep 28 '22 18:09

Joseph