Get the FREE Ultimate OpenClaw Setup Guide →

Java -For-SMTP-Mailing

A Model Context Protocol (MCP) server (using java sdk 0.11.0) that provides email sending capabilities through SMTP integration. This server acts as a bridge between MCP-compatible AI assistants (like Claude Desktop) and email services.

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio rayenmalouche-java-mcp-server-for-smtp-mailing java -jar <FULL_PATH_TO_PROJECT>/target/RayenMalouche-0.0.1-SNAPSHOT.jar --sse \
  --env JAVA_HOME="<JAVA_HOME_PATH>"

How to use

This MCP server provides email sending capabilities via SMTP using a Java-based MCP server that can communicate over STDIO, Server-Sent Events (SSE), and a Streamable HTTP transport. It exposes a send-email tool for MCP clients and also offers REST endpoints for testing and health checks. You can connect MCP clients such as Claude Desktop or MCP Inspector to the server through the supported transports or use the REST API to validate email sending flows. The SMTP configuration targets Gmail by default, but the setup supports other SMTP providers by adjusting the SMTP host, port, and TLS settings in the Java configuration. The included REST endpoints enable quick health checks and basic email sending tests, helpful for automation and testing workflows.

How to install

Prerequisites:

  • Java 21+ JDK
  • Maven 3.6+
  • Access to an SMTP server (e.g., Gmail with app-specific password) or another SMTP provider

Installation steps:

  1. Clone the repository
git clone https://github.com/RayenMalouche/Java-MCP-Server-For-SMTP-Mailing.git
cd Java-MCP-Server-For-SMTP-Mailing
  1. Configure email settings Edit the SMTP configuration in the application source or properties as shown in the README, for example:
// SMTP Configuration - Update these values
private static final String SMTP_USERNAME = "your-email@gmail.com";
private static final String SMTP_PASSWORD = "your-app-password";
private static final String SMTP_HOST = "smtp.gmail.com";
private static final int SMTP_PORT = 587;
private static final boolean SMTP_TLS_ENABLED = true;
private static final boolean SMTP_SSL_ENABLED = false;
  1. Build the project
mvn clean compile
mvn clean package -DskipTests   # builds the jar without tests
# or to run tests
#mvn clean package
  1. Run the server (example for STDIO transport)
java -jar target/RayenMalouche-0.0.1-SNAPSHOT.jar --stdio
  1. Verify transports
  • For SSE:
java -jar target/RayenMalouche-0.0.1-SNAPSHOT.jar --sse
  • For Streamable HTTP:
java -jar target/RayenMalouche-0.0.1-SNAPSHOT.jar --streamable-http
  1. Optional: integrate with MCP clients using the provided configuration examples in the README (Claude Desktop/MCP Inspector) by specifying the Java path and the built jar path.

Additional notes

Tips and considerations:

  • Ensure your SMTP credentials are secured; use app passwords or environment variables where possible.
  • If you enable TLS, confirm the SMTP host and port match your provider's requirements (e.g., Gmail: smtp.gmail.com:587 with TLS).
  • The MCP CLI/Inspector can test all three transports; use the appropriate command to validate connectivity.
  • The server supports health checks via REST endpoints; monitor endpoints under /health or similar paths described in the API reference.
  • If you encounter port conflicts, configure the SSE or HTTP transports to listen on different ports where applicable.
  • When deploying in CI, consider injecting SMTP credentials via environment variables and avoiding hard-coded secrets.

Related MCP Servers

Sponsor this space

Reach thousands of developers