rutaj6 Posted July 19, 2017 Posted July 19, 2017 Just wondering about my options,Is there nay way to setup a trigger on an email id, for arrival of email. The moment an email arrives, a particular JavaScript or PHP file can be called and triggered.Just if it is possible and would not put too much load on the server!
wolstech Posted July 19, 2017 Posted July 19, 2017 You can pipe the email into a script so that the script receives the email and can act upon its contents. Take a look at the "advanced options" under the email forwarder settings in cpanel.
Krydos Posted July 19, 2017 Posted July 19, 2017 Go to https://tommy.heliohost.org:2083/frontend/paper_lantern/mail/pops.html and create the email address we're going to use in this tutorial. For this example we'll use admin@rutaj6.heliohost.org Now go to https://tommy.heliohost.org:2083/frontend/paper_lantern/mail/filters/managefilters.html and click "Manage Filters" next to the email address we just created. Click "Create New Filter". Name the filter "Pipe Test". For testing let's set it to trigger whenever the Subject contains the string "Pipe Test". Select "Pipe to a Program". In the box type|/home/rutaj6/email/email_handler.phpThat first character is a pipe which is a vertical line. If you want the email to be delivered to your inbox in addition to piping to your script you can click the + on the right side, and set up Deliver to Folder: Inbox. This way it'll pipe it to your script AND put it in the inbox. Create /home/rutaj6/email/email_handler.php with permissions 755. The first two lines are very important. The first line has to be the shebang which is #! and then the path to the PHP version you want to use. The -q flag suppresses the output of php headers. If you echo any output of any kind in your script it will be emailed back to the sender as an error. This includes headers. The second line has to be <?php There can't be any blank lines or random characters or windows line endings. Any of that stuff will mess it up.#!/opt/cpanel/ea-php71/root/usr/bin/php-cgi -q <?php // listen for incoming emails $sock = fopen("php://stdin", "r"); $email = ""; // read email into buffer while (!feof($sock)) { $email .= fread($sock, 1024); } // close socket fclose($sock); // log received email $file = "/home/rutaj6/email/email.log"; $fh = fopen($file, 'a'); fwrite($fh, "$email\n\n\n"); Create /home/rutaj6/email/email.log with permissions 644. Now send an email to yourself at admin@rutaj6.heliohost.org and make sure "Pipe Test" is in the subject line to trigger the filter. If everything worked it should write your email to /home/rutaj6/email/email.log. From there the sky is the limit. You can process this raw input as much as you want and do whatever. Also, completely unrelated to this tutorial, please be aware that each user is only allowed one account as stated in our Terms of Service. Please delete all accounts in excess of one by going to http://www.heliohost.org/classic/support/scripts/delete Possessing more than one account could result in all of your accounts being suspended. Let us know if you need help consolidating your accounts down into one.
rutaj6 Posted July 20, 2017 Author Posted July 20, 2017 Sorry about not reading the TOS perfectly, i will transfer all data and then delete the second account!Thanks for all the support!
rutaj6 Posted July 20, 2017 Author Posted July 20, 2017 Final Update: Account was successfully deleted and I have successfully transferred everything. Thanks for all the support!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now