COURIER_PORT
COURIER PORT tells courier which port to run on
SMTP_HOST
SMTP Host is the domain name associated with your SMTP server for gmail, it is smtp.gmail.com
SMTP_PASSWORD
This is your authentication method to the SMTP server, for gmail, it is your google password
SMTPUser
This is your authentication method to the SMTP server, for gmail, it is your google username/emailaddress
All configuration options above are provided in the docker-compose.yml and may be overidden at your discretion
- build the docker image
docker build -t courier .
- overide the environment variables in the docker-compose file,
docker-compose up
- Courier is now running on your system!
- you now need a method to communicate to the courier server, you may use the example client located in
cmd/client/main/go
or you may write your own
- Courier exposes a gRPC interface, so you are able to use the generated code in the pb package.
- Create a connection to the Courier instance
// Set up a connection to the server. conn, err := grpc.Dial(address, grpc.WithInsecure()) if err != nil { log.Fatalf("did not connect: %v", err) } defer conn.Close() c := pb.NewMailClient(conn)
- Send a message to whoever you wish by, sending a message like:
// Contact the server and print out its response.
r, err := c.Send(context.Background(), &pb.SendBody{
Recipients: []string{"[email protected]"},
Sender: "[email protected]",
Subject: "Hello, to my friends",
BodyText: "Just saying hi",
BodyType: "text/html",
})
- That's all it takes