Forum Moderators: coopster
We did a simple thing that in retrospect was brilliant: We wrote a program that asks every engineer what they did every week. It sends them e-mail on Monday, and concatenates the e-mails together in a document that everyone can read. And it then sends that out to everyone and shames those who did not answer by putting them on the top of the list. It has run reliably every week since we started, so for every week of our company's history we have a record of what everyone did.
Basically I want to write a script just like that. Question: what's the best way to capture the email replies so I can process them? Create a script that acts as a POP or IMAP client? Via the filesystem somehow (I'm using qmail)? Is there a another way?
If anyone can point me in the right direction...
P.S. - Been doing about of CLI scripts in PHP lately and loving it :)
As Rubenski suggested, you could do this from a web based app. You could write a script to mail everyone on Monday with a link to the web page... A lot less coding that way.
And not that the HTML form wouldn't be easier, just that acceptance among the userbase will probably be better if email is the "interface" (not to mention it would be a cool thing to know how to do <-- the real reason, hehe). I appreciate the suggestions, though, keep them coming.
Incoming Mail and PHP [evolt.org]
I found the instructions here
I've been wondering if I could create a script that would adjust a mailing list when someone sends a reply to a specific address, such as unsubscribe@mydomain.com. I had no idea where to start. I'm working on a subscription/e-newsletter mailing system, and that is one of the things I was worried about.
This is going to take a lot of experimentation and a lot of calls to my server admin guy. If anyone has any pre-cooked solutions, please share!
thanks!
If it was me I'd be looking at the POP3 classes at sourceforge. There's also all sorts of PHP web based mail programs that somehow can grab an email off a POP3 account. If it was me I'd be figuring out how they do it.
<Nick's link is pretty cool but it requires PHP compiled as a CGI binary. I'm not too up on that.>
I think that is enabled by default in PHP =>4.3.
<Can you have PHP compiled as an Apache module and a CGI binary at the same time?>
Yes.. having the command-line interface compiled just means that you've created a binary called "php", usually /usr/bin/php. You can have either the CLI compiled, the Apache module, or both. They don't interfere with each other, and creating scripts for it works just like creating a script in Perl (the first line is the path to the php binary).
The following code is the framework of what I used:
# ******************************************************************
$imap_stream = imap_open($mailbox, $userid, $userpassword);
if(!$imap_stream) die("Error opening a stream to the IMAP server! " . imap_last_error());
$mssg_count = imap_num_msg($imap_stream);
if ($mssg_count){
for($the_mssg_id=0; $the_mssg_id<=$mssg_count; ++$the_mssg_id){#loop for each message
# process messages here
$this_header = imap_fetchheader ($imap_stream,$the_mssg_id,FT_UID);
}
}else{
echo ("There are NO messages");
}
if(!imap_close($imap_stream)) die("Error closing the stream!");
# ******************************************************************
I hope this helps.
Bob