MailFort is an email service project that allows you to send confirmation emails and password reset emails. It provides flexibility in configuration and supports both gRPC and REST API for interaction.
To run the MailFort service, follow these steps:
-
Fill out the configuration file: Create a configuration file (e.g.,
local.yaml
) and provide the necessary configurations for the MailFort service. You can find an example configuration file in theconfig
directory. -
Export the configuration path: Set the environment variable
CONFIG_PATH
to point to your configuration file.
export CONFIG_PATH=./config/local.yaml
-
Add credential for mail client: Create file
.env
and write parameters. -
Run in development mode: Start the MailFort service in development mode using the task command:
task dev
MailFort supports interaction through both gRPC and REST API.
To interact with MailFort using gRPC, you can use the generated gRPC client. Below is an example in Go:
// Example gRPC client
package main
import (
"context"
"log"
"time"
"google.golang.org/grpc"
pb "path/to/mailfort/pb" // Import your generated gRPC package
"github.com/8thgencore/mailfort/internal/config"
)
func main() {
// Create a gRPC connection to MailFort service
conn, err := grpc.Dial("localhost:44044", grpc.WithInsecure())
if err != nil {
log.Fatalf("Failed to connect: %v", err)
}
defer conn.Close()
// Create a MailFort client
client := pb.NewMailFortClient(conn)
// Example: Send Confirmation Email
confirmationReq := &pb.ConfirmationRequest{
Email: "[email protected]",
Code: "123456",
}
_, err = client.SendConfirmationEmail(context.Background(), confirmationReq)
if err != nil {
log.Fatalf("Failed to send confirmation email: %v", err)
}
// Example: Send Password Reset Email
resetReq := &pb.ResetPasswordRequest{
Email: "[email protected]",
Code: "654321",
}
_, err = client.SendPasswordResetEmail(context.Background(), resetReq)
if err != nil {
log.Fatalf("Failed to send password reset email: %v", err)
}
}
MailFort also provides a RESTful API for interaction. Below are examples using curl
:
curl -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]","code":"123456"}' http://localhost:8080/api/send-confirmation-email
curl -X POST -H "Content-Type: application/json" -d '{"email":"[email protected]","code":"654321"}' http://localhost:8080/api/send-password-reset-email
Make sure to replace the example email addresses and codes with your actual data.
Feel free to adapt the examples based on your programming language and preferred HTTP client library for REST API interaction.