Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to affect a PHP program / mysql database from an email response

I am trying to work out how to do something. It must be possible - I've seen something similar done in multiple systems (Twitter, facebook etc.)

The basic thing I want to do is - someone leaves a comment on my website. The comment goes to my email, as well as to my MySql database. I then reply directly on my email. The reply is saved to the database, and auto-approves the user's comment.

I can't work out how to speak to my MySql / PHP system directly from an email. Also - I can't work out how to set up the inboxes?

I am guessing that I'd need to set up mailserver rules so that emails sent to [email protected] are actually redirected to a php script, where xxxx is an identifier of the original comment?

Thanks for any light that you can shed...

like image 541
whizzkid Avatar asked Feb 22 '26 08:02

whizzkid


1 Answers

Assuming you're on a unix system, you could set up an account for receiving the mail, e.g. "fred", and use a .forward in fred's home directory to pipe emails to your php script. e.g.

.forward:

|"/usr/bin/php /path/to/your/script.php"

which will invoke your script anytime an email arrives in fred's mailbox.

like image 97
Marc B Avatar answered Feb 24 '26 21:02

Marc B