smtp callback on new email
I have a custom app that i built which relies on a cron job to check for new email every 5 minutes. If there is a new email it then performs an action. What I would like to do is have a callback fired off when a new email arrives and then 开发者_如何学运维perform the action.
I could set the cron job to 1min intervals ( currently it is set to 5min ) but this seems like a waste of resources. The app is built in php and any help would be appreciated, i am just not sure what direction i should be looking at them moment.
M
You could use something like MailGun or SendGrid's Parse API which will receive your email for you and callback to an endpoint you specify.
very basic mail pipe script:
#!/usr/bin/php -q
<?php
// read from stdin
$fd = fopen("php://stdin","r");
$email = "";
while ( !feof($fd) ){
$email .= fread($fd,1024);
}
fclose($fd);
?>
what you do with $email, depends on what you need
精彩评论