tcjohans Posted October 1, 2007 Share Posted October 1, 2007 Hi! I want to build a PHP-based mailing list manager. The problem is how to handle processes initiated by emails, say if a person sends an email from his/her regular email program or webmail site (hotmail, aol, pandora, whatever), e.g. to send an email message to a list he/she is subscribed to or to send an email for automatic unsubscription (with "unsubscribe" in the subject line) from a list, etc. How would the manager handle such a process? Is there a way to get a server to automatically run a PHP script whenever, say, an email comes in addressed to some email address at @lists.MYDOMAIN.org (say if the email is addressed to SOMELIST@lists.MYDOMAIN.org)? Or could I solve the problem by using some other scripting language, say, Perl or Python (which I don't know too well currently)? Thomas Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/ Share on other sites More sharing options...
trq Posted October 1, 2007 Share Posted October 1, 2007 You need to look at the documentation for your MTA. What MTA are you using? Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-358772 Share on other sites More sharing options...
tcjohans Posted October 1, 2007 Author Share Posted October 1, 2007 I see. I need to hear with the server company hosting my site for that. Have sent them an email and will get back as soon as I hear from them. They're not in this time zone though, so it will probably take a day. Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-358788 Share on other sites More sharing options...
tcjohans Posted October 1, 2007 Author Share Posted October 1, 2007 Actually, I can tell this much about my server so far (maybe this gives some indication of the mail server??): Apache version 1.3.37 (Unix) PHP version 5.2.4 MySQL version 5.0.27-standard Architecture i686 Operating system Linux Path to sendmail /usr/sbin/sendmail Path to PERL /usr/bin/perl Kernel version 2.6.18-8.1.8.el5 Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-358789 Share on other sites More sharing options...
tcjohans Posted October 2, 2007 Author Share Posted October 2, 2007 You need to look at the documentation for your MTA. What MTA are you using? Ok, so the MTA is exim 4.68 ... Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-359798 Share on other sites More sharing options...
cooldude832 Posted October 2, 2007 Share Posted October 2, 2007 A workaround would involve using cURL to open your webmail client and then taking that page's data and extracting it and using it as you needed, but I don't know what details you are looking. You might want to look into the PEAR extension as it does a lot with mail and might be able to help you. Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-359813 Share on other sites More sharing options...
tcjohans Posted October 3, 2007 Author Share Posted October 3, 2007 A workaround would involve using cURL to open your webmail client and then taking that page's data and extracting it and using it as you needed, but I don't know what details you are looking. You might want to look into the PEAR extension as it does a lot with mail and might be able to help you. I am not sure I understand what you mean here. What I need is a way to get a php script to run when an email comes in to the mail server posted to an email address that ends with "@lists.MYDOMAIN.org" - the php script would process it, e.g. if it is addressed to a mailing list it would check the MySQL mailing list database for a list of all subscribers to the list in question and then mail it off to them. Alternatively, an idea that came to my head today: If the mail server can just make sure to store/save all such incoming mail for some reasonable amount of time - without responding or reacting to them in any particular way -, then I should be able set up a cron job that executes a php file regularly to check all such incoming mail and performing the appropriate processes for each (e.g. forwarding to the appropriate mailing list, unsubscibe the email address, subscribe the email address, etc.) But I don't know anything about mail servers at this stage. Does any of these solutions make sense and be feasible? Or how do other script-based mailing list managers handle this particular problem - i.e. how to handle incoming mail? Thomas Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-360576 Share on other sites More sharing options...
tcjohans Posted October 5, 2007 Author Share Posted October 5, 2007 A solution that somebody proposed on another site is just to open a mailbox - pr one for each mailing list - on the mailserver, get incoming mail directed to these, and then use cron to set a php to process them regularly at short intervals. Quote Link to comment https://forums.phpfreaks.com/topic/71306-how-to-make-a-server-run-a-script-when-an-email-arrives/#findComment-362222 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.