Exemplo n.º 1
0
    def test_process_message_should_delegate_to_a_route_registered_with_it(self):
        class RouteImpl(Route):

            def route(self, route=r'*****@*****.**'):
                self.called = True

        message =  'To: Benjamin <*****@*****.**>, [email protected], Eric <*****@*****.**>\nFrom: Ben Coe <*****@*****.**>'

        server = Server(('0.0.0.0', 10465), None)
        server.add_route(RouteImpl)
        server.process_message(('0.0.0.0', '333'), '*****@*****.**', '*****@*****.**', message)
Exemplo n.º 2
0
    server.quit()

    messages_sent += 1.0

########NEW FILE########
__FILENAME__ = server
import time
from smtproutes import Route, Server
from smtproutes.decorators import route

class BenchmarkRoute(Route):
    @route(r'(?P<prefix>[^@]*)@(?P<suffix>.*)')
    def benchmark_route(self):
        pass

Server(('0.0.0.0', 10025), None).add_route(BenchmarkRoute).start()

########NEW FILE########
__FILENAME__ = example_route
import smtproutes
import logging

from smtproutes import Route, Server
from smtproutes.sender_auth import DKIMAuth, GmailSPFAuth, SPFAuth
from smtproutes.decorators import route

class ExampleRoute(Route):
    
    @route(r'(?P<prefix>open)@(?P<suffix>.*)')
    def open_route(self):
        print "%s at %s triggered route with message: \n\n %s" % (
Exemplo n.º 3
0
from smtproutes import Route, Server
from pymongo import Connection

subscribers = Connection('vmimage').mailing_list.subscribers


class MailingList(Route):
    def subscribe(self, route=r'subscribe-(?P<name>[^@]*)@.*'):
        subscribers.update({
            'email': self.mailfrom.email,
        }, {'$set': {
            'email': self.mailfrom.email,
            'name': self.name
        }},
                           upsert=True)

    def unsubscribe(self, route=r'unsubscribe@.*'):
        subscribers.remove({'email': self.mailfrom.email})


Server(('0.0.0.0', 25), None).add_route(MailingList).start()
Exemplo n.º 4
0
import time
from smtproutes import Route, Server
from smtproutes.decorators import route

class BenchmarkRoute(Route):
    @route(r'(?P<prefix>[^@]*)@(?P<suffix>.*)')
    def benchmark_route(self):
        pass
        
Server(('0.0.0.0', 25), None).add_route(BenchmarkRoute).start()
Exemplo n.º 5
0
from smtproutes.decorators import route


class ExampleRoute(Route):
    @route(r'(?P<prefix>open)@(?P<suffix>.*)')
    def open_route(self):
        print "%s at %s triggered route with message: \n\n %s" % (
            self.prefix, self.suffix, self.message)

    @route(r'(?P<prefix>dkim)@(?P<suffix>.*)', sender_auth=DKIMAuth)
    def dkim_route(self):
        print "%s at %s triggered route with message: \n\n %s" % (
            self.prefix, self.suffix, self.message)

    @route(r'(?P<prefix>spf)@(?P<suffix>.*)', sender_auth=SPFAuth)
    def spf_route(self):
        print "%s at %s triggered route with message: \n\n %s" % (
            self.prefix, self.suffix, self.message)

    @route(r'(?P<prefix>spf_google)@(?P<suffix>.*)',
           sender_auth=[SPFAuth, GmailSPFAuth])
    def google_apps_spf_route(self):
        print "%s at %s triggered route with message: \n\n %s" % (
            self.prefix, self.suffix, self.message)


logger = logging.getLogger(smtproutes.LOG_NAME)
logger.setLevel(logging.INFO)

Server(('0.0.0.0', 25), None).add_route(ExampleRoute).start()