Let's say I have a linux server and I want to catch emails sent to a specific regular expression of an email address (298358.this@domain.com and 895830935.that@domain.com, but not phice@domain.com) and process them with a PHP file. I've seen this done with moblog scripts that will catch emails to a specific email. If it had to be a specific email that would even be fine, but I would much rather prefer a regular expression-based, or something like it, to do this process.
Example: If I send an email to 285803.test@domain.com, I want the linux box to catch that email and process it with a PHP file (body, subject, to, etc. Then I can store that email to whatever I want.
Any idea's going about doing this? If you need any further information, just look at any moblog company. It's the same exact setup.
Catching mail and processing it with PHP
Moderator: General Moderators
Related scripts:
http://www.veryfewwords.com/MTpop2blog.txt
http://www.guid.org/oss/pop2blog/pop2blog.pl.txt
Though it's in Perl, would I need to keep it in Perl and how would I go about installing something like that?
http://www.veryfewwords.com/MTpop2blog.txt
http://www.guid.org/oss/pop2blog/pop2blog.pl.txt
Though it's in Perl, would I need to keep it in Perl and how would I go about installing something like that?
As usual, i would use "fetchmail-ssl" to fecth e-mails from wherever...
And use "procmail" to process them.
I believe .procmailrc would look like (untested)
And use "procmail" to process them.
I believe .procmailrc would look like (untested)
Code: Select all
##
:0
* ^TO_\d+\.this@domain\.com$\
^TO_\d+\.that@domain\.com$
| `php script.php`Make the incoming mail forward to your script. I have used perl in the past to process the emails but I will be converting this all to php whenever I get around to ordering another server for testing.
php would have to be installed as a CGI though. I may be wrong but you may be able to just install a php command line interpreter.
php would have to be installed as a CGI though. I may be wrong but you may be able to just install a php command line interpreter.