Blog Logo

12 Sep 2023 ~ 2 min read

Go Contact API & Send Email

This API is designed to handle contact form submissions, store contact information in a MongoDB database, and send a confirmation email. It provides endpoints to submit contact information and receive confirmation messages.

Table of Contents

Getting Started


Before running the API, ensure you have the following prerequisites installed:


  1. Clone the repository:

    git clone
  2. Navigate to the project directory:

    cd contact-api
  3. Create a .env file in the project root and configure the following environment variables:

  4. Build and run the API:

    go build

The API should now be running on the specified port.


API Endpoints

Submit Contact Information

  • Endpoint: /api/contact
  • Method: POST
  • Request Body:
      "firstName": "John",
      "lastName": "Doe",
      "email": "",
      "linkedin": "",
      "tech": "Go, JavaScript",
      "message": "Hello, I'm interested in your services."
  • Response:
      "message": "Data saved successfully and email sent!"

Environment Variables

  • MONGODB_URI: MongoDB connection URI.
  • SMTP_HOST: SMTP server host.
  • SMTP_PORT: SMTP server port.
  • SMTP_USERNAME: SMTP server username.
  • SMTP_PASSWORD: SMTP server password.
  • PORT: Port on which the API should run.


Contributions are welcome! Please feel free to open issues or pull requests.

Developed By

Francisco Inoque

Headshot of Francisco Inoque

Hello, I'm Francisco Inoque, an experienced Back-End Developer with expertise in Node.js, Go, and Python. I thrive on solving complex development challenges and am eager to contribute to innovative projects. Let's connect and discuss how I can help you achieve your goals efficiently!