{"id":13412702,"url":"https://github.com/mocktools/go-smtp-mock","last_synced_at":"2026-04-09T01:00:34.201Z","repository":{"id":39333449,"uuid":"401721985","full_name":"mocktools/go-smtp-mock","owner":"mocktools","description":"SMTP mock server written on Golang. Mimic any 📤 SMTP server behavior for your test environment with fake SMTP server.","archived":false,"fork":false,"pushed_at":"2026-04-08T22:59:28.000Z","size":323,"stargazers_count":164,"open_issues_count":5,"forks_count":23,"subscribers_count":5,"default_branch":"master","last_synced_at":"2026-04-09T00:36:42.466Z","etag":null,"topics":["developer-tools","fake-server","fake-smtp-server","go","go-smtp","golang","hacktoberfest","mock-server","mocktools","smtp","smtp-mail","smtp-mock","smtp-server","smtplib","testing","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mocktools.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["bestwebua"]}},"created_at":"2021-08-31T13:54:57.000Z","updated_at":"2026-04-08T22:57:28.000Z","dependencies_parsed_at":"2023-11-16T22:55:13.572Z","dependency_job_id":"ea1aaf83-f1e4-47fc-b7b9-8285b621dc02","html_url":"https://github.com/mocktools/go-smtp-mock","commit_stats":{"total_commits":112,"total_committers":5,"mean_commits":22.4,"dds":0.0535714285714286,"last_synced_commit":"278329c7f06c95c6ae6f3264645cb244162619dc"},"previous_names":[],"tags_count":48,"template":false,"template_full_name":null,"purl":"pkg:github/mocktools/go-smtp-mock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fgo-smtp-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fgo-smtp-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fgo-smtp-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fgo-smtp-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mocktools","download_url":"https://codeload.github.com/mocktools/go-smtp-mock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mocktools%2Fgo-smtp-mock/sbom","scorecard":{"id":655799,"data":{"date":"2025-08-11","repo":{"name":"github.com/mocktools/go-smtp-mock","commit":"a58c3d6af907129318e4ddb805185082aeb21a3c"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":4.4,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":4,"reason":"security policy file detected","details":["Info: security policy file detected: SECURITY.md:1","Warn: no linked content found","Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1","Info: Found text in security policy: SECURITY.md:1"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Code-Review","score":0,"reason":"Found 2/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":8,"reason":"9 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE.txt:0","Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v2.5.1 not signed: https://api.github.com/repos/mocktools/go-smtp-mock/releases/227331718","Warn: release artifact v2.5.0 not signed: https://api.github.com/repos/mocktools/go-smtp-mock/releases/222219368","Warn: release artifact v2.4.0 not signed: https://api.github.com/repos/mocktools/go-smtp-mock/releases/186617974","Warn: release artifact v2.3.3 not signed: https://api.github.com/repos/mocktools/go-smtp-mock/releases/185803402","Warn: release artifact v2.3.2 not signed: https://api.github.com/repos/mocktools/go-smtp-mock/releases/185367331","Warn: release artifact v2.5.1 does not have provenance: https://api.github.com/repos/mocktools/go-smtp-mock/releases/227331718","Warn: release artifact v2.5.0 does not have provenance: https://api.github.com/repos/mocktools/go-smtp-mock/releases/222219368","Warn: release artifact v2.4.0 does not have provenance: https://api.github.com/repos/mocktools/go-smtp-mock/releases/186617974","Warn: release artifact v2.3.3 does not have provenance: https://api.github.com/repos/mocktools/go-smtp-mock/releases/185803402","Warn: release artifact v2.3.2 does not have provenance: https://api.github.com/repos/mocktools/go-smtp-mock/releases/185367331"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T14:36:41.554Z","repository_id":39333449,"created_at":"2025-08-21T14:36:41.555Z","updated_at":"2025-08-21T14:36:41.555Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31580507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["developer-tools","fake-server","fake-smtp-server","go","go-smtp","golang","hacktoberfest","mock-server","mocktools","smtp","smtp-mail","smtp-mock","smtp-server","smtplib","testing","testing-tools"],"created_at":"2024-07-30T20:01:28.056Z","updated_at":"2026-04-09T01:00:34.161Z","avatar_url":"https://github.com/mocktools.png","language":"Go","funding_links":["https://github.com/sponsors/bestwebua"],"categories":["Email","电子邮件","Relational Databases"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","Advanced Console UIs"],"readme":"# ![SMTP mock server written on Golang. Mimic any SMTP server behavior for your test environment with fake SMTP server](https://repository-images.githubusercontent.com/401721985/848bc1dd-fc35-4d78-8bd9-0ac3430270d8)\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/mocktools/go-smtp-mock/v2)](https://goreportcard.com/report/github.com/mocktools/go-smtp-mock/v2)\n[![Codecov](https://codecov.io/gh/mocktools/go-smtp-mock/branch/master/graph/badge.svg)](https://codecov.io/gh/mocktools/go-smtp-mock)\n[![CircleCI](https://circleci.com/gh/mocktools/go-smtp-mock/tree/master.svg?style=svg)](https://circleci.com/gh/mocktools/go-smtp-mock/tree/master)\n[![GitHub release (latest by date)](https://img.shields.io/github/v/release/mocktools/go-smtp-mock)](https://github.com/mocktools/go-smtp-mock/releases)\n[![PkgGoDev](https://pkg.go.dev/badge/github.com/mocktools/go-smtp-mock/v2)](https://pkg.go.dev/github.com/mocktools/go-smtp-mock/v2)\n[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go)\n[![GitHub](https://img.shields.io/github/license/mocktools/go-smtp-mock)](LICENSE.txt)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v1.4%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\n`smtpmock` is lightweight configurable multithreaded fake SMTP server written in Go. It meets the minimum requirements specified by [RFC 2821](https://datatracker.ietf.org/doc/html/rfc2821) \u0026 [RFC 5321](https://datatracker.ietf.org/doc/html/rfc5321). Allows to mimic any SMTP server behavior for your test environment and even more 🚀\n\n## Table of Contents\n\n- [Features](#features)\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Inside of Golang ecosystem](#inside-of-golang-ecosystem)\n    - [Configuring](#configuring)\n    - [Manipulation with server](#manipulation-with-server)\n    - [Using a custom logger](#using-a-custom-logger)\n  - [Inside of Ruby ecosystem](#inside-of-ruby-ecosystem)\n    - [Example of usage](#example-of-usage)\n  - [Inside of any ecosystem](#inside-of-any-ecosystem)\n    - [Configuring with command line arguments](#configuring-with-command-line-arguments)\n    - [Other options](#other-options)\n    - [Stopping server](#stopping-server)\n  - [Implemented SMTP commands](#implemented-smtp-commands)\n- [Contributing](#contributing)\n- [License](#license)\n- [Code of Conduct](#code-of-conduct)\n- [Credits](#credits)\n- [Versioning](#versioning)\n- [Changelog](CHANGELOG.md)\n\n## Features\n\n- Configurable multithreaded RFC compatible SMTP server\n- Implements the minimum command set, responds to commands and adds a valid received header to messages as specified in [RFC 2821](https://datatracker.ietf.org/doc/html/rfc2821) \u0026 [RFC 5321](https://datatracker.ietf.org/doc/html/rfc5321)\n- Ability to configure behavior for each SMTP command\n- Comes with default settings out of the box, configure only what you need\n- Ability to override previous SMTP commands\n- Fail fast scenario (ability to close client session for case when command was inconsistent or failed)\n- Multiple receivers (ability to configure multiple `RCPT TO` commands receiving during one session)\n- Multiple message receiving (ability to configure multiple message receiving during one session)\n- Mock-server activity logger\n- Ability to do graceful/force shutdown of SMTP mock server\n- No authentication support\n- Zero runtime dependencies\n- Ability to access to server messages\n- Simple and intuitive DSL\n- Ability to run server as binary with command line arguments\n\n## Requirements\n\nGolang 1.15+\n\n## Installation\n\nInstall `smtpmock`:\n\n```bash\ngo get github.com/mocktools/go-smtp-mock/v2\ngo install github.com/mocktools/go-smtp-mock/v2\n```\n\nImport `smtpmock` dependency into your code:\n\n```go\npackage main\n\nimport smtpmock \"github.com/mocktools/go-smtp-mock/v2\"\n```\n\n## Usage\n\n- [Inside of Golang ecosystem](#inside-of-golang-ecosystem)\n  - [Configuring](#configuring)\n  - [Manipulation with server](#manipulation-with-server)\n  - [Using a custom logger](#using-a-custom-logger)\n- [Inside of Ruby ecosystem](#inside-of-ruby-ecosystem)\n  - [Example of usage](#example-of-usage)\n- [Inside of any ecosystem](#inside-of-any-ecosystem)\n  - [Configuring with command line arguments](#configuring-with-command-line-arguments)\n  - [Other options](#other-options)\n  - [Stopping server](#stopping-server)\n- [Implemented SMTP commands](#implemented-smtp-commands)\n\n### Inside of Golang ecosystem\n\nYou have to create your SMTP mock server using `smtpmock.New()` and `smtpmock.ConfigurationAttr{}` to start interaction with it.\n\n#### Configuring\n\n`smtpmock` is SMTP server for test environment with configurable behavior. It comes with default settings out of the box. But you can override any default behavior if you need.\n\n```go\nsmtpmock.ConfigurationAttr{\n\n  // Customizing server behavior\n  // ---------------------------------------------------------------------\n  // Host address where smtpmock will run, it's equal to \"127.0.0.1\" by default\n  HostAddress:                   \"[::]\",\n\n  // Port number on which the server will bind. If it not specified, it will be\n  // assigned dynamically after server.Start() by default\n  PortNumber:                    2525,\n\n  // Enables/disables log to stdout. It's equal to false by default\n  LogToStdout:                   true,\n\n  // Enables/disables log server activity. It's equal to false by default\n  LogServerActivity:             true,\n\n  // Ability to specify session timeout. It's equal to 30 seconds by default\n  SessionTimeout:                42,\n\n  // Ability to specify graceful shutdown timeout. It's equal to 1 second by default\n  ShutdownTimeout:               5,\n\n\n  // Customizing SMTP command handlers behavior\n  // ---------------------------------------------------------------------\n  // Ability to configure fail fast scenario. It means that server will\n  // close client session for case when command was inconsistent or failed.\n  // It's equal to false by default\n  IsCmdFailFast:                 true,\n\n  // Ability to configure multiple RCPT TO command receiving during one session.\n  // It means that server will handle and save all RCPT TO command request-response\n  // pairs until receive successful response and next SMTP command has been passed.\n  // Please note, by default will be saved only one, the last RCPT TO command\n  // request-response pair. It's equal to false by default\n  MultipleRcptto:                true,\n\n  // Ability to configure multiple message receiving during one session. It means that server\n  // will create another message during current SMTP session in case when RSET\n  // command has been used after successful commands chain: MAIL FROM, RCPT TO, DATA.\n  // Please note, by default RSET command flushes current message in any case.\n  // It's equal to false by default\n  MultipleMessageReceiving:      true,\n\n  // Ability to specify blacklisted HELO domains. It's equal to empty []string\n  BlacklistedHeloDomains:        []string{\"example1.com\", \"example2.com\", \"localhost\"},\n\n  // Ability to specify blacklisted MAIL FROM emails. It's equal to empty []string\n  BlacklistedMailfromEmails:     []string{\"bot@olo.com\", \"robot@molo.com\"},\n\n  // Ability to specify blacklisted RCPT TO emails. It's equal to empty []string\n  BlacklistedRcpttoEmails:       []string{\"blacklisted@olo.com\", \"blacklisted@molo.com\"},\n\n  // Ability to specify not registered (non-existent) RCPT TO emails.\n  // It's equal to empty []string\n  NotRegisteredEmails:           []string{\"nobody@olo.com\", \"non-existent@email.com\"},\n\n  // Ability to specify HELO response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayHelo:             2,\n\n  // Ability to specify MAIL FROM response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayMailfrom:         2,\n\n  // Ability to specify RCPT TO response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayRcptto:           2,\n\n  // Ability to specify DATA response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayData:             2,\n\n  // Ability to specify message response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayMessage:          2,\n\n  // Ability to specify RSET response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayRset:             2,\n\n  // Ability to specify NOOP response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayNoop:             2,\n\n  // Ability to specify QUIT response delay in seconds. It runs immediately,\n  // equals to 0 seconds by default\n  ResponseDelayQuit:             2,\n\n  // Ability to specify message body size limit. It's equal to 10485760 bytes (10MB) by default\n  MsgSizeLimit:                  5,\n\n\n  // Customizing SMTP command handler messages context\n  // ---------------------------------------------------------------------\n  // Custom server greeting message. Base on defaultGreetingMsg by default\n  MsgGreeting:                   \"msgGreeting\",\n\n  // Custom invalid command message. Based on defaultInvalidCmdMsg by default\n  MsgInvalidCmd:                 \"msgInvalidCmd\",\n\n  // Custom invalid command HELO sequence message.\n  // Based on defaultInvalidCmdHeloSequenceMsg by default\n  MsgInvalidCmdHeloSequence:     \"msgInvalidCmdHeloSequence\",\n\n  // Custom invalid command HELO argument message.\n  // Based on defaultInvalidCmdHeloArgMsg by default\n  MsgInvalidCmdHeloArg:          \"msgInvalidCmdHeloArg\",\n\n  // Custom HELO blacklisted domain message. Based on defaultQuitMsg by default\n  MsgHeloBlacklistedDomain:      \"msgHeloBlacklistedDomain\",\n\n  // Custom HELO received message. Based on defaultReceivedMsg by default\n  MsgHeloReceived:               \"msgHeloReceived\",\n\n  // Custom invalid command MAIL FROM sequence message.\n  // Based on defaultInvalidCmdMailfromSequenceMsg by default\n  MsgInvalidCmdMailfromSequence: \"msgInvalidCmdMailfromSequence\",\n\n  // Custom invalid command MAIL FROM argument message.\n  // Based on defaultInvalidCmdMailfromArgMsg by default\n  MsgInvalidCmdMailfromArg:      \"msgInvalidCmdMailfromArg\",\n\n  // Custom MAIL FROM blacklisted email message. Based on defaultQuitMsg by default\n  MsgMailfromBlacklistedEmail:   \"msgMailfromBlacklistedEmail\",\n\n  // Custom MAIL FROM received message. Based on defaultReceivedMsg by default\n  MsgMailfromReceived:           \"msgMailfromReceived\",\n\n  // Custom invalid command RCPT TO sequence message.\n  // Based on defaultInvalidCmdRcpttoSequenceMsg by default\n  MsgInvalidCmdRcpttoSequence:   \"msgInvalidCmdRcpttoSequence\",\n\n  // Custom invalid command RCPT TO argument message.\n  // Based on defaultInvalidCmdRcpttoArgMsg by default\n  MsgInvalidCmdRcpttoArg:        \"msgInvalidCmdRcpttoArg\",\n\n  // Custom RCPT TO not registered email message.\n  // Based on defaultNotRegisteredRcpttoEmailMsg by default\n  MsgRcpttoNotRegisteredEmail:   \"msgRcpttoNotRegisteredEmail\",\n\n  // Custom RCPT TO blacklisted email message. Based on defaultQuitMsg by default\n  MsgRcpttoBlacklistedEmail:     \"msgRcpttoBlacklistedEmail\",\n\n  // Custom RCPT TO received message. Based on defaultReceivedMsg by default\n  MsgRcpttoReceived:             \"msgRcpttoReceived\",\n\n  // Custom invalid command DATA sequence message.\n  // Based on defaultInvalidCmdDataSequenceMsg by default\n  MsgInvalidCmdDataSequence:     \"msgInvalidCmdDataSequence\",\n\n  // Custom DATA received message. Based on defaultReadyForReceiveMsg by default\n  MsgDataReceived:               \"msgDataReceived\",\n\n  // Custom size is too big message. Based on defaultMsgSizeIsTooBigMsg by default\n  MsgMsgSizeIsTooBig:            \"msgMsgSizeIsTooBig\",\n\n  // Custom received message body message. Based on defaultReceivedMsg by default\n  MsgMsgReceived:                \"msgMsgReceived\",\n\n  // Custom invalid command RSET sequence message.\n  // Based on defaultInvalidCmdHeloSequenceMsg by default\n  MsgInvalidCmdRsetSequence:     \"msgInvalidCmdRsetSequence\",\n\n  // Custom invalid command RSET message. Based on defaultInvalidCmdMsg by default\n  MsgInvalidCmdRsetArg:           \"msgInvalidCmdRsetArg\",\n\n  // Custom RSET received message. Based on defaultOkMsg by default\n  MsgRsetReceived:               \"msgRsetReceived\",\n\n  // Custom NOOP received message. Based on defaultOkMsg by default\n  MsgNoopReceived:               \"msgNoopReceived\",\n\n  // Custom quit command message. Based on defaultQuitMsg by default\n  MsgQuitCmd:                    \"msgQuitCmd\",\n}\n```\n\n#### Manipulation with server\n\n```go\npackage main\n\nimport (\n  \"fmt\"\n  \"net\"\n  \"net/smtp\"\n\n  smtpmock \"github.com/mocktools/go-smtp-mock/v2\"\n)\n\nfunc main() {\n  // You can pass empty smtpmock.ConfigurationAttr{}. It means that smtpmock will use default settings\n  server := smtpmock.New(smtpmock.ConfigurationAttr{\n    LogToStdout:       true,\n    LogServerActivity: true,\n  })\n\n  // To start server use Start() method\n  if err := server.Start(); err != nil {\n    fmt.Println(err)\n  }\n\n  // Server's port will be assigned dynamically after server.Start()\n  // for case when portNumber wasn't specified\n  hostAddress, portNumber := \"127.0.0.1\", server.PortNumber()\n\n  // Possible SMTP-client stuff for iteration with mock server\n  address := fmt.Sprintf(\"%s:%d\", hostAddress, portNumber)\n  timeout := time.Duration(2) * time.Second\n\n  connection, _ := net.DialTimeout(\"tcp\", address, timeout)\n  client, _ := smtp.NewClient(connection, hostAddress)\n  client.Hello(\"example.com\")\n  client.Quit()\n  client.Close()\n\n  // Each result of SMTP session will be saved as message.\n  // To get access for server messages copies use Messages() method\n  server.Messages()\n\n  // To get access for server messages copies and purge it on server after\n  // use MessagesAndPurge() method\n  server.MessagesAndPurge()\n\n  // In case with flaky test environment you can wait for the specified number\n  // of messages to arrive or until timeout is reached use WaitForMessages() method\n  server.WaitForMessages(42, 1 * time.Millisecond)\n\n  // In case with flaky test environment you can wait for the specified number\n  // of messages to arrive or until timeout is reached and purge it on server\n  // after use WaitForMessagesAndPurge() method\n  server.WaitForMessagesAndPurge(42, 1 * time.Millisecond)\n\n  // To stop the server use Stop() method. Please note, smtpmock uses graceful shutdown.\n  // It means that smtpmock will end all sessions after client responses or by session\n  // timeouts immediately.\n  if err := server.Stop(); err != nil {\n    fmt.Println(err)\n  }\n}\n```\n\nCode from example above will produce the following output to the configured logger:\n\n```code\nINFO: 2021/11/30 22:07:30.554827 SMTP mock server started on port: 2525\nINFO: 2021/11/30 22:07:30.554961 SMTP session started\nINFO: 2021/11/30 22:07:30.554998 SMTP response: 220 Welcome\nINFO: 2021/11/30 22:07:30.555059 SMTP request: EHLO example.com\nINFO: 2021/11/30 22:07:30.555648 SMTP response: 250 Received\nINFO: 2021/11/30 22:07:30.555686 SMTP request: QUIT\nINFO: 2021/11/30 22:07:30.555722 SMTP response: 221 Closing connection\nINFO: 2021/11/30 22:07:30.555732 SMTP session finished\nWARNING: 2021/11/30 22:07:30.555801 SMTP mock server is in the shutdown mode and won't accept new connections\nINFO: 2021/11/30 22:07:30.555808 SMTP mock server was stopped successfully\n```\n\n#### Using a custom logger\n\n```go\npackage main\n\nimport (\n  \"bytes\"\n  \"fmt\"\n  \"net\"\n  \"net/smtp\"\n\n  smtpmock \"github.com/mocktools/go-smtp-mock/v2\"\n)\n\n// User-defined loggers can be defined by implementing the Logger interface.\n// For example, this custom logger writes to byte buffers instead of os.Stdout/Stderr.\ntype customLogger struct {\n  out *bytes.Buffer\n  err *bytes.Buffer\n}\n\nfunc (logger *customLogger) InfoActivity(message string) {\n  logger.out.WriteString(message)\n}\n\nfunc (logger *customLogger) Info(message string) {\n  logger.out.WriteString(message)\n}\n\nfunc (logger *customLogger) Warning(message string) {\n  logger.out.WriteString(message)\n}\n\nfunc (logger *customLogger) Error(message string) {\n  logger.err.WriteString(message)\n}\n\nfunc main() {\n  // You can pass empty smtpmock.ConfigurationAttr{}. It means that smtpmock will use default settings\n  server := smtpmock.New(smtpmock.ConfigurationAttr{\n    LogToStdout:       true,\n    LogServerActivity: true,\n  })\n\n  // The default logger for the server can be substituted with a custom logging implementation.\n  // This can be useful in tests where the server logs need to be programatically examined.\n  outBuf := \u0026bytes.Buffer{}\n  errBuf := \u0026bytes.Buffer{}\n  server.WithLogger(\u0026customLogger{\n    out: outBuf,\n    err: errBuf,\n  })\n\n  // To start server use Start() method\n  if err := server.Start(); err != nil {\n    fmt.Println(err)\n  }\n\n  // To stop the server use Stop() method. Please note, smtpmock uses graceful shutdown.\n  // It means that smtpmock will end all sessions after client responses or by session\n  // timeouts immediately.\n  if err := server.Stop(); err != nil {\n    fmt.Println(err)\n  }\n}\n```\n\n### Inside of Ruby ecosystem\n\nIn Ruby ecosystem `smtpmock` is available as [`smtp_mock`](https://github.com/mocktools/ruby-smtp-mock) gem. It's flexible Ruby wrapper over `smtpmock` binary.\n\n#### Example of usage\n\nFirst, you should install `smtp_mock` gem and `smtpmock` as system dependency:\n\n```bash\ngem install smtp_mock\nbundle exec smtp_mock -i ~\n```\n\nNow, you can create and interact with your `smtpmock` instance natively from Ruby ecosystem. It comes with default settings out of the box. Configure only what you need, for example:\n\n```ruby\nrequire 'smtp_mock'\n\n# List of all available server options:\n# https://github.com/mocktools/ruby-smtp-mock#available-server-options\nsmtp_mock_server = SmtpMock.start_server(not_registered_emails: %w[user@olo.com user@molo.com])\n\n# returns current smtp mock server port\nsmtp_mock_server.port # =\u003e 55640\n\n# interface for force shutdown current smtp mock server\nsmtp_mock_server.stop! # =\u003e true\n```\n\n### Inside of any ecosystem\n\nYou can use `smtpmock` as binary. Just download the pre-compiled binary from the [releases page](https://github.com/mocktools/go-smtp-mock/releases) and copy them to the desired location. For start server run command with needed arguments. You can use our bash script for automation this process like in the example below:\n\n```bash\ncurl -sL https://raw.githubusercontent.com/mocktools/go-smtp-mock/master/script/download.sh | bash\n./smtpmock -port=2525 -log\n```\n\n#### Configuring with command line arguments\n\n`smtpmock` configuration is available as command line arguments specified in the list below:\n\n| Flag description | Example of usage |\n| --- | --- |\n| `-host` - host address where smtpmock will run. It's equal to `127.0.0.1` by default | `-host=localhost` |\n| `-port` - server port number. If not specified it will be assigned dynamically | `-port=2525` |\n| `-log` - enables log server activity. Disabled by default | `-log` |\n| `-sessionTimeout` - session timeout in seconds. It's equal to 30 seconds by default | `-sessionTimeout=60` |\n| `-shutdownTimeout` - graceful shutdown timeout in seconds. It's equal to 1 second by default | `-shutdownTimeout=5` |\n| `-failFast` - enables fail fast scenario. Disabled by default | `-failFast` |\n| `-multipleRcptto` - enables multiple `RCPT TO` receiving scenario. Disabled by default | `-multipleRcptto` |\n| `-multipleMessageReceiving` - enables multiple message receiving scenario. Disabled by default | `-multipleMessageReceiving` |\n| `-blacklistedHeloDomains` - blacklisted `HELO` domains, separated by commas | `-blacklistedHeloDomains=\"example1.com,example2.com\"` |\n| `-blacklistedMailfromEmails` - blacklisted `MAIL FROM` emails, separated by commas | `-blacklistedMailfromEmails=\"a@example1.com,b@example2.com\"` |\n| `-blacklistedRcpttoEmails` - blacklisted `RCPT TO` emails, separated by commas | `-blacklistedRcpttoEmails=\"a@example1.com,b@example2.com\"` |\n| `-notRegisteredEmails` - not registered (non-existent) `RCPT TO` emails, separated by commas | `-notRegisteredEmails=\"a@example1.com,b@example2.com\"` |\n| `-responseDelayHelo` - `HELO` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayHelo=2` |\n| `-responseDelayMailfrom` - `MAIL FROM` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayMailfrom=2` |\n| `-responseDelayRcptto` - `RCPT TO` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayRcptto=2` |\n| `-responseDelayData` - `DATA` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayData=2` |\n| `-responseDelayMessage` - Message response delay in seconds. It's equal to 0 seconds by default | `-responseDelayMessage=2` |\n| `-responseDelayRset` - `RSET` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayRset=2` |\n| `-responseDelayNoop` - `NOOP` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayNoop=2` |\n| `-responseDelayQuit` - `QUIT` response delay in seconds. It's equal to 0 seconds by default | `-responseDelayQuit=2` |\n| `-msgSizeLimit` - message body size limit in bytes. It's equal to `10485760` bytes | `-msgSizeLimit=42` |\n| `-msgGreeting` - custom server greeting message | `-msgGreeting=\"Greeting message\"` |\n| `-msgInvalidCmd` - custom invalid command message | `-msgInvalidCmd=\"Invalid command message\"` |\n| `-msgInvalidCmdHeloSequence` - custom invalid command `HELO` sequence message | `-msgInvalidCmdHeloSequence=\"Invalid command HELO sequence message\"` |\n| `-msgInvalidCmdHeloArg` - custom invalid command `HELO` argument message | `-msgInvalidCmdHeloArg=\"Invalid command HELO argument message\"` |\n| `-msgHeloBlacklistedDomain` - custom `HELO` blacklisted domain message | `-msgHeloBlacklistedDomain=\"Blacklisted domain message\"` |\n| `-msgHeloReceived` - custom `HELO` received message | `-msgHeloReceived=\"HELO received message\"` |\n| `-msgInvalidCmdMailfromSequence` - custom invalid command `MAIL FROM` sequence message | `-msgInvalidCmdMailfromSequence=\"Invalid command MAIL FROM sequence message\"` |\n| `-msgInvalidCmdMailfromArg` - custom invalid command `MAIL FROM` argument message | `-msgInvalidCmdMailfromArg=\"Invalid command MAIL FROM argument message\"` |\n| `-msgMailfromBlacklistedEmail` - custom `MAIL FROM` blacklisted email message | `-msgMailfromBlacklistedEmail=\"Blacklisted email message\"` |\n| `-msgMailfromReceived`- custom `MAIL FROM` received message | `-msgMailfromReceived=\"MAIL FROM received message\"` |\n| `-msgInvalidCmdRcpttoSequence` - custom invalid command `RCPT TO` sequence message | `-msgInvalidCmdRcpttoSequence=\"Invalid command RCPT TO sequence message\"` |\n| `-msgInvalidCmdRcpttoArg` - custom invalid command `RCPT TO` argument message | `-msgInvalidCmdRcpttoArg=\"Invalid command RCPT TO argument message\"` |\n| `-msgRcpttoNotRegisteredEmail` - custom `RCPT TO` not registered email message | `-msgRcpttoNotRegisteredEmail=\"Not registered email message\"` |\n| `-msgRcpttoBlacklistedEmail` - custom `RCPT TO` blacklisted email message | `-msgRcpttoBlacklistedEmail=\"Blacklisted email message\"` |\n| `-msgRcpttoReceived` - custom `RCPT TO` received message | `-msgRcpttoReceived=\"RCPT TO received message\"` |\n| `-msgInvalidCmdDataSequence` - custom invalid command `DATA` sequence message | `-msgInvalidCmdDataSequence=\"Invalid command DATA sequence message\"` |\n| `-msgDataReceived` - custom `DATA` received message | `-msgDataReceived=\"DATA received message\"` |\n| `-msgMsgSizeIsTooBig` - custom size is too big message | `-msgMsgSizeIsTooBig=\"Message size is too big\"` |\n| `-msgMsgReceived` - custom received message body message | `-msgMsgReceived=\"Message has been received\"` |\n| `-msgInvalidCmdRsetSequence` - custom invalid command `RSET` sequence message | `-msgInvalidCmdRsetSequence=\"Invalid command RSET sequence message\"` |\n| `-msgInvalidCmdRsetArg` - custom invalid command `RSET` message | `-msgInvalidCmdRsetArg=\"Invalid command RSET message\"` |\n| `-msgRsetReceived` - custom `RSET` received message | `-msgRsetReceived=\"RSET received message\"` |\n| `-msgNoopReceived` - custom `NOOP` received message | `-msgNoopReceived=\"NOOP received message\"` |\n| `-msgQuitCmd` - custom `QUIT` command message | `-msgQuitCmd=\"Quit command message\"` |\n\n#### Other options\n\nAvailable not configuration `smtpmock` options:\n\n| Flag description | Example of usage |\n| --- | --- |\n| `-v` - Just prints current `smtpmock` binary build data (version, commit, datetime). Doesn't run the server. | `-v` |\n\n#### Stopping server\n\n`smtpmock` accepts 3 shutdown signals: `SIGINT`, `SIGQUIT`, `SIGTERM`.\n\n### Implemented SMTP commands\n\n| id | Command | Sequenceable | Available args | Example of usage |\n| --- | --- | --- | --- | --- |\n| `1` | `HELO` | no | `domain name`, `localhost`, `ip address`, `[ip address]` | `HELO example.com` |\n| `1` | `EHLO` | no | `domain name`, `localhost`, `ip address`, `[ip address]` | `EHLO example.com` |\n| `2` | `MAIL FROM` | can be used after command with id `1` and greater | `email address`, `\u003cemail address\u003e`, `localhost email address`, `\u003clocalhost email address\u003e` | `MAIL FROM: user@domain.com` |\n| `3` | `RCPT TO` | can be used after command with id `2` and greater | `email address`, `\u003cemail address\u003e`, `localhost email address`, `\u003clocalhost email address\u003e` | `RCPT TO: user@domain.com` |\n| `4` | `DATA` | can be used after command with id `3` | - | `DATA` |\n| `5` | `RSET` | can be used after command with id `1` and greater | - | `RSET` |\n| `6` | `NOOP` | no | - | `NOOP` |\n| `7` | `QUIT` | no | - | `QUIT` |\n\nPlease note in case when same command used more the one time during same session all saved data upper this command will be erased.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at \u003chttps://github.com/mocktools/go-smtp-mock\u003e. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. Please check the [open tickets](https://github.com/mocktools/go-smtp-mock/issues). Be sure to follow Contributor Code of Conduct below and our [Contributing Guidelines](CONTRIBUTING.md).\n\n## License\n\nThis golang package is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the `smtpmock` project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n\n## Credits\n\n- [The Contributors](https://github.com/mocktools/go-smtp-mock/graphs/contributors) for code and awesome suggestions\n- [The Stargazers](https://github.com/mocktools/go-smtp-mock/stargazers) for showing their support\n\n## Versioning\n\n`smtpmock` uses [Semantic Versioning 2.0.0](https://semver.org)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmocktools%2Fgo-smtp-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmocktools%2Fgo-smtp-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmocktools%2Fgo-smtp-mock/lists"}