(self, request)
return json.dumps({
            "message": "Queued. Thank you.",
            "id": message_id})
Responds with response code 200 with a generic response body.

        If the `to` address is `bademail@example.com` results in error 500
        and if it is `failingemail@example.com` results in 400.
Responds with response code 200 with a generic response body.
Responds with response code 200 with a generic response body .
def send_messages(self, request):
        """
        Responds with response code 200 with a generic response body.

        If the `to` address is `bademail@example.com` results in error 500
        and if it is `failingemail@example.com` results in 400.
        """
        content = parse_qs(request.content.read().decode("utf-8"))
        to_address = content.get('to')
        headers = {}
        for key, value in content.items():
            if key.startswith("h:") or key.startswith("v:"):
                headers[key] = value

        if 'bademail@example.com' in to_address:
            request.setResponseCode(500)
            global count
            count += 1
            return b''

        if 'failingemail@example.com' in to_address:
            request.setResponseCode(400)
            return b''

        request.setResponseCode(200)
        message_id = "{0}@samples.mailgun.org".format(
            seconds_to_timestamp(time.time(),
                                 "%Y%m%d%H%M%S.%f"))
        self.core.message_store.add_to_message_store(
            message_id=message_id,
            to=content.get('to')[0], msg_from=content.get('from'),
            subject=content.get('subject')[0], body=content.get('html'),
            custom_headers=headers)
        return json.dumps({
            "message": "Queued. Thank you.",
            "id": message_id})
def send_messages ( self , request ) : content = parse_qs ( request . content . read ( ) . decode ( "utf-8" ) ) to_address = content . get ( 'to' ) headers = { } for key , value in content . items ( ) : if key . startswith ( "h:" ) or key . startswith ( "v:" ) : headers [ key ] = value if 'bademail@example.com' in to_address : request . setResponseCode ( 500 ) global count count += 1 return b'' if 'failingemail@example.com' in to_address : request . setResponseCode ( 400 ) return b'' request . setResponseCode ( 200 ) message_id = "{0}@samples.mailgun.org" . format ( seconds_to_timestamp ( time . time ( ) , "%Y%m%d%H%M%S.%f" ) ) self . core . message_store . add_to_message_store ( message_id = message_id , to = content . get ( 'to' ) [ 0 ] , msg_from = content . get ( 'from' ) , subject = content . get ( 'subject' ) [ 0 ] , body = content . get ( 'html' ) , custom_headers = headers ) return json . dumps ( { "message" : "Queued. Thank you." , "id" : message_id } )