Coder Social home page Coder Social logo

going-postal's Introduction

going-postal

An Azure function with a HTTP trigger for sending email to an SMTP endpoint, to be used with concurrency for load testing.

Documentation

/send

Methods

POST

Body

{
    "endpoint": "smtp.some-endpoint.com",
    "port": 25,
    "timeout": 3.5,
    "tenant_id": "f45af6e4-4206-4e5b-8675-d4852a158dbf",
    "recipient": "[email protected]",
    "sender": "[email protected]"
}

All fields are required, with the exception of:

  • port, which defaults to 25 if not specified.
  • timeout, which defaults to null if not specified.

Responses

  • 200: if email successfully sent to endpoint.
  • 400: if request body not present or malformed.
  • 500: if there was a general error in the function.
  • 502: if there was some error sending the email to the SMTP endpoint.

Development

Requirements

  • Serverless framework
  • Python 3.8
  • Pipenv

Quick start

  1. Clone this repo.
  2. Set up your pipenv by running pipenv sync --dev.
  3. Launch the function with pipenv run serverless offline --region uksouth.
  4. Edit the code and test. I use HTTPie for making requests.
  5. In order to have something to test with, you can run a postfix blackhole mail server on port 25 using Docker, with: docker run --name blackhole -d -p 25:25 simap/smtpblackhole.
  6. Now, using HTTPie to make a request to the locally running function: http post http://localhost:7071/api/send endpoint=localhost port=25 tenant_id=test [email protected] [email protected].
  7. You should get back something like this:
    HTTP/1.1 200 OK
    Content-Type: text/plain; charset=utf-8
    Date: Tue, 30 Jun 2020 13:51:51 GMT
    Server: Kestrel
    Transfer-Encoding: chunked
    
    Successfully sent to 'localhost:25'
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.