[PR #279] [CLOSED] Added send message API endpoint #501

Closed
opened 2026-03-15 14:22:20 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/axllent/mailpit/pull/279
Author: @ryan0x44
Created: 4/18/2024
Status: Closed

Base: developHead: send-message-api


📝 Commits (1)

  • 02ab5b3 Added send message API endpoint

📊 Changes

4 files changed (+319 additions, -2 deletions)

View changed files

📝 server/apiv1/api.go (+201 -0)
📝 server/apiv1/swagger.go (+115 -0)
📝 server/server.go (+1 -0)
📝 server/smtpd/smtpd.go (+2 -2)

📄 Description

This adds an API endpoint for sending messages via HTTP, per feature request #278

Example usage:

 curl -X POST http://localhost:8025/api/v1/messages \
     -H "Content-Type: application/json" \
     -d '{
          "from": { "email": "sender@example.com" },
          "to": [{
              "email": "recipient@example.com"
          }],
          "subject": "hello",
          "html": "<html><body>Hello</body></html>",
          "text": "Hello"
        }'

Note that in order to re-use code, I had to make the smtpd package mailHandler method public.

Open to suggestions for any changes but thought it would be nice to put something together to at least solve my immediate need.

Thanks for building mailpit!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/axllent/mailpit/pull/279 **Author:** [@ryan0x44](https://github.com/ryan0x44) **Created:** 4/18/2024 **Status:** ❌ Closed **Base:** `develop` ← **Head:** `send-message-api` --- ### 📝 Commits (1) - [`02ab5b3`](https://github.com/axllent/mailpit/commit/02ab5b36ae9dbeeb1b43c16e230736993d0cfcc2) Added send message API endpoint ### 📊 Changes **4 files changed** (+319 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `server/apiv1/api.go` (+201 -0) 📝 `server/apiv1/swagger.go` (+115 -0) 📝 `server/server.go` (+1 -0) 📝 `server/smtpd/smtpd.go` (+2 -2) </details> ### 📄 Description This adds an API endpoint for sending messages via HTTP, per feature request #278 Example usage: ``` curl -X POST http://localhost:8025/api/v1/messages \ -H "Content-Type: application/json" \ -d '{ "from": { "email": "sender@example.com" }, "to": [{ "email": "recipient@example.com" }], "subject": "hello", "html": "<html><body>Hello</body></html>", "text": "Hello" }' ``` Note that in order to re-use code, I had to make the smtpd package `mailHandler` method public. Open to suggestions for any changes but thought it would be nice to put something together to at least solve my immediate need. Thanks for building mailpit! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-15 14:22:20 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/mailpit#501
No description provided.