Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using RPC over email?

Can someone tell me how they have done this in some form, be it XML-RPC, SOAP, bespoke etc. Not too worried on the packet format.

I am interested in doing some sort of RPC over email, setting up a program to receive commands via email from another application(s) or even from users on a subscription list. Basically the idea is you give someone the email address and then send messages to active commands, and the response is back in email. A good example of where I would be taking this is maybe a chess program, where time is irrelevant but delivery is everything and sequential ordering of moves is a given.

I would be most interested in the experiences of others, especially with the nature of email and any idiosyncratic behaviour that I should be aware of.

I have quite a bit of experience of RPC over Message Queues and asynchronous delivery, but would like to come up with a solution where I shift the communications on to hotmail or gmail, freeing up my servers and the headache of the asynchronous intercoms.

like image 224
WeNeedAnswers Avatar asked Jun 29 '26 08:06

WeNeedAnswers


1 Answers

I'm already doing this with Google AppEngine and Python. It's really simple.

In your app.yaml file you need to setup that you will using the email service and you file to manage them:

application: appname
version: 1
runtime: python
api_version: 1

handlers:
- url: /_ah/mail/.+
  script: mail.py
  login: admin

inbound_services:
- mail

Then create a mail.py file with something like this:

#!/usr/bin/env python

import rfc822
import logging

from google.appengine.ext import db
from google.appengine.ext import webapp 
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler 
from google.appengine.ext.webapp.util import run_wsgi_app

class LogSenderHandler(InboundMailHandler):
    def receive(self, message):
        service_name, service_email = rfc822.parseaddr(message.to)
        service_request = service_email.split('@').pop(0)
        sender_name, sender_email = rfc822.parseaddr(message.sender)

        logging.info('Service `%s` activated by `%s`.' % (service_request, sender_email))

if __name__ == '__main__':
    application = webapp.WSGIApplication(
        [LogSenderHandler.mapping()])
    run_wsgi_app(application)

All you need to do is send an email to [email protected]. Voila!

like image 52
joksnet Avatar answered Jul 01 '26 22:07

joksnet