Forward email to script for processing?
Hi there,
I'd like to set up a system that processes incoming mail to a specific address that I'll set up. The system might scan the subject string and act accordingly. Specifically, I'd like the system to be controlled by email. I've had a hard time finding specific information on the 'net about doing this. I'm running Postfix on a Centos box, but I really don't want to mess with configuration of what's already a well-working system. Can anyone offer specific advice on how to forward the fields of an email to a PHP script for processing? Thanks in advance, Aaron. |
If you setup procmail for mail delivery, you can tell procmail to pass incoming mail to a user-defined script.
|
I'm not terribly familiar with procmail. I thought that a procmailrc file had to be sitting in a particular user folder to work -- and was tied to that user's email address? Where would I put it to handle delivery for a non-user-specific account?
Thanks, Aaron. |
Hi
You can also use a .forward file in the home directory of the user on that server. Normally, you can put an email address here to have the email forwarded, but you can also specify a script if you prefix it with a "|". For example: You want a php script (/usr/local/bin/webmaster-email.php) to get emails sent to "webmaster@yoursite.org". 1) create the user "webmaster" on the server 2) create a /home/webmaster/.forward file and put "|/usr/local/bin/webmaster-email.php" in it (without the quotes) 3) first line of /usr/local/bin/webmaster-email.php should be #!/usr/bin/php (path to your php) 4) chmod 755 /usr/local/bin/webmaster-email.php The reason it's good to use a system account is that it's nice to control under which user the script will run. You probably don't want to run it as root. When the script executes, reading from stdin will give you the email. Code:
#!/usr/bin/php To get the email's body, scan the lines until you find a blank line. The body is after that line. And: Quote:
webslave: webmaster |
Hi Guttorm...
I know that this thread is very old, but it is the nearest thread that I have found to my problem. If you are still monitoring this thread would you please respond. I have a problem that I have been trying to reslove for days and can't find and answer. Regards, John C |
That should be: "Please respond here:"
http://www.linuxquestions.org/questi...script-855718/ That's the current theread. |
Thanks moderator.
The thread that you directed me to is MINE. However, I saw that there was a previous thread and wanted to ask Guttorm a question about it. I can't find an email address for him or anywhere to send him a message other than here. John C |
You're welcome.
We don't allow cross- or double- posting at LQ, so I wanted to make sure that Guttorm answered you in the appropriate place. |
Hi Rick...
I had no intention of cross- or double- posting. I just want to contact Guttorm. Can you suggest how I might get in touch with Guttorm ??? Thanks, John C |
Quote:
I just wanted to be sure that the same issue wasn't being discussed in 2 threads, so I added a link to the main/current discussion. I thought posting here was a reasonable way to contact Guttorm. In addition to this, you could leave a VM (Visitor Message) here: http://www.linuxquestions.org/questi...guttorm-88727/ |
Thanks Rick...
|
All times are GMT -5. The time now is 12:37 PM. |