Jump to content

How to make a server run a script when an email arrives?


tcjohans

Recommended Posts

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

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.