Sending of activation mail to the user
Create a project directory. Set GOPATH enviroment variable to that project. Add $GOPATH/bin to the $PATH
export GOPATH=/path/to/project
export PATH=$GOPATH/bin:$PATH
Clone the repo:
cd $GOPATH/src
git clone git@github.com:Microkubes/microservice-mail.git
Install the dependencies:
dep ensure -v
Then compile and run:
cd microservice-mail
go build -o microservice-mail
./microservice-mail
From root of the project run:
go test -v $(go list ./... | grep -v vendor)
To build the docker image run:
docker build -t microkubes/microservice-mail .
To run the service type:
docker run -it -e SERVICE_CONFIG_FILE=config.json microkubes/microservice-mail
The service loads the configuration from a JSON file /run/secrets/microservice_mail_config.json. To change the path set the SERVICE_CONFIG_FILE env var.
For testing purposes you may want to enable sending the email notifications to a local SMTP server over unencrypted connection. To allow this, you must set:
export ALLOW_UNENCRYPTED_CONNECTION=true
Note: Be careful not to allow sending email over unencrypted connection in production mode!
Here's an example of a JSON configuration file:
{
"templatesBaseLocation": "./public/template/",
"templates": {
"templateName": {
"filename" : "template-filename.html",
"subject": "Subject of the mail",
"data": {
"example": "value"
}
}
},
"mail": {
"host": "fakesmtp",
"port": "25",
"user": "fake@email.com",
"password": "password",
"email": "dev@microkubes.org"
},
"rabbitmq": {
"username": "guest",
"password": "guest",
"host": "rabbitmq",
"port": "5672"
}
}
Send message to AMQP topic "email-queue" formatted in the following structure
type AMQPMessage struct {
Email string `json:"email,omitempty"`
Template string `json:"template,omitempty"`
Data map[string]string `json:"data,omitempty"`
}
Email json["email"] - "Send To" Email
Template json["template"] - name of the template defined in config.json
Data json["data"] - map with all properties that are required by the template
For contributing to this repository or its documentation, see the Contributing guidelines.