Git Product home page Git Product logo

serverless-app's Introduction

Serverless Email Service

This project is a serverless REST API built using the Serverless Framework, AWS Lambda, and AWS SES (Simple Email Service). The API allows you to send emails by providing the recipient's email address, subject, and body text.

Prerequisites

  • Node.js
  • AWS CLI (configured with appropriate permissions)
  • Serverless Framework

Setup

  1. Install Serverless Framework:

    • Run npm install -g serverless
  2. Initialize the Project:

    • Run serverless create --template aws-nodejs --path serverless-email
    • Navigate to the project directory: cd serverless-email
  3. Install Dependencies:

    • Run npm init -y
    • Run npm install aws-sdk
  4. Update serverless.yml File:

    • Define the service, provider, functions, events, plugins, and IAM role statements required for sending emails using SES.
  5. Create handler.js:

    • Implement the Lambda function code to send an email using AWS SES, including input validation and error handling.
  6. Deploy the Service:

    • Run serverless deploy

Running Locally

To test the service offline:

  1. Start Serverless Offline:

    • Run serverless offline
  2. Test with Postman:

    • URL: http://localhost:3000/send-email

    • Method: POST

    • Headers:

      • Content-Type: application/json
    • Body:

      {
        "receiver_email": "[email protected]",
        "subject": "Test Email",
        "body_text": "This is a test email."
      }
    • Expected Responses:

      • 200 OK:
        {
          "message": "Email sent successfully"
        }
      • 400 Bad Request:
        {
          "message": "receiver_email, subject, and body_text are required."
        }
      • 500 Internal Server Error:
        {
          "message": "Internal Server Error"
        }

Notes

  • Ensure the Source email in handler.js is verified in AWS SES.
  • Modify the region in serverless.yml if using a different AWS region.
  • Check the console for detailed error messages if issues arise.

License

This project is licensed under the MIT License.

serverless-app's People

Contributors

amanjaiswal7236 avatar

Watchers

 avatar

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.