Skip to content

burakberkkeskin/gomtp

Repository files navigation

📬 GOMTP

Gomtp is a cli tool to test smtp settings easily.

Install

Install From Binary (Recommended)

You can install the gomtp to Linux or macOS with these commands:

sudo curl -L -o /usr/local/bin/gomtp "https://github.com/safderun/gomtp/releases/latest/download/gomtp-$(uname -s)-$(uname -m)" && \
sudo chmod +x /usr/local/bin/gomtp

Build Locally

You can build the gomtp locally, on your own machine.

version=$(git describe --tags --abbrev=0) && \
commitId=$(git rev-parse --short $version) && \
go build -ldflags "-X gomtp/cmd.version=$version -X gomtp/cmd.commitId=$commitId" -o gomtp -v .

Usage

  • Create a gomtp.yaml file anywhre you want.
  • Take the template from the gomtp.yaml
  • There is 4 templates for mailhog, gmail, yandex and brevo
  • subject and body is optional.
  • In the same directory with your configured gomtp.yaml, run gomtp with no argument.
❯ gomtp
Email sent successfully!
  • If your configuration is valid, you will see the "Email sent successfully!" message.

Custom Gomtp Yaml Path

  • You can name the gomtp.yaml as you wish while creating the configuration.

  • If you change the default configuration file name, you can pass the path of the file to the gomtp.

gomtp --file test.yaml

or

gomtp -f test.yaml

Sample SMTP For Testing

  • To test the gomtp quickly, you can run the mailhog from docker-compose.yml
docker compose up -d
  • Configure gomtp.yaml
    • The default gomtp.yaml file has been configured for the mailhog.
  • Open the mailhog web ui from http://127.0.0.1:8025
  • Run the gomtp.
gomtp

Release a version

  • Define a version.
export gomtpVersion=v1.4.0
  • You should create a release branch from the master
git checkout master && git pull && \
git checkout -b release/${gomtpVersion}
  • Tag the commit
git tag --sign ${gomtpVersion} -m "Added verifyCertificate and example commands."
  • Push the release branch and tags
git push && git push --tags

Run Tests

  • Before run the tests, run the docker compose file.
docker compose up -d
  • You can run e2e tests to ensure application stability.
go test -c -o gomtp.test ./cmd/ && \
./gomtp.test
  • Check the test coverage:
go test -coverprofile=coverage.out -c -o gomtp.test ./cmd/ && \
./gomtp.test -test.coverprofile ./c.out
  • You can see covered lines with html report:
go test -coverprofile=coverage.out -c -o gomtp.test ./cmd/ && \
./gomtp.test -test.coverprofile ./c.out && \
go tool cover -html=c.out