{"id":22339781,"url":"https://github.com/scriptollc/mockmailer","last_synced_at":"2025-08-01T23:42:22.365Z","repository":{"id":57300195,"uuid":"21431071","full_name":"scriptoLLC/mockmailer","owner":"scriptoLLC","description":"A mock for nodemailer","archived":false,"fork":false,"pushed_at":"2018-10-08T17:32:01.000Z","size":10,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-07-23T13:19:45.736Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/scriptoLLC.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-02T16:18:37.000Z","updated_at":"2017-06-21T20:32:52.000Z","dependencies_parsed_at":"2022-09-15T19:40:53.716Z","dependency_job_id":null,"html_url":"https://github.com/scriptoLLC/mockmailer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/scriptoLLC/mockmailer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fmockmailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fmockmailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fmockmailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fmockmailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scriptoLLC","download_url":"https://codeload.github.com/scriptoLLC/mockmailer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scriptoLLC%2Fmockmailer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268314657,"owners_count":24231031,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-01T02:00:08.611Z","response_time":67,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-12-04T07:09:22.702Z","updated_at":"2025-08-01T23:42:22.335Z","avatar_url":"https://github.com/scriptoLLC.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![build status](https://secure.travis-ci.org/scriptoLLC/mockmailer.png)](http://travis-ci.org/scriptoLLC/mockmailer)\n\n# mockmailer\n\n[![Greenkeeper badge](https://badges.greenkeeper.io/scriptoLLC/mockmailer.svg)](https://greenkeeper.io/)\n\nA test framework agnostic mock for [nodemailer](https://github.com/andris9/Nodemailer) allowing you to test code that sends mail via nodemailer without actually sending mail.\n\nObviously you'll need `nodemailer` installed in your app that you're trying to test. This will use that version to prevent any oddities with two copies of nodemailer being present.\n\n## Usage\n```javascript\nvar test = require('tap').test;\nvar mockmailer = require('mockmailer');\nvar nodemailer = require('nodemailer');\n\ntest('do not send mail', function(t){\n  var transport = nodemailer.createTransport('SMTP', {options: 'go here'});\n  var sendOptions = {to: 'test@test.com'};\n  var triggered = false;\n\n  mockmailer(function(err, message){\n    t.ok(triggered, 'Triggered original callback')\n    t.ok(!err, 'Did not return an error');\n    t.deepEqual(message.options, sendOptions, 'Returned correct options');\n    t.equal(message.messageId, 'noid', 'mockmailer ID returned');\n    t.equal(message.message, 'Caught by mockmailer', 'mockmailer message returned');\n    t.end();\n  });\n\n  transport.sendMail(sendOptions, function(){\n    triggered = true;\n  });\n});\n\ntest('simulate a failure', function(t){\n  var transport = nodemailer.createTransport('STMP', {service: 'immafail'});\n  var triggered = false;\n  mockmailer.setFail(true);\n  mockmailer(function(err, message){\n    t.ok(err, 'Returned an error');\n    t.ok(triggered, 'Triggered original callback');\n    t.equal(err.message, 'failed by user request', 'Message is from mockmailer');\n    t.end();\n    mockmailer.setFail(false);\n  });\n\n  transport.sendMail({}, function(err){\n    if(err){\n      triggered = true;\n    }\n  });\n});\n\n```\n\n## Installation\n\n```\nnpm i -D mockmailer\n```\n\n## API\n\n### mockmailer → `function(registeredCallback)`\n\n```\n/**\n * Supply a callback to be invoked when mail is sent that resolves or fails your test\n * @method  mockmailer\n * @async\n * @param   {function} registeredCallback The callback to invoke when `sendMail` is called\n * @returns {object} undefined\n */\n```\n\n### setFail → `function(fail)`\n```\n/**\n * Sets nodemailer to either fail or not when `sendMail` is called\n * @method setFail\n * @param  {boolean} mode Should nodemailer \"fail\" sending mail\n */\n```\n\n## License\nmockmailer is ©2014 Scripto, LLC. Available for use under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptollc%2Fmockmailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscriptollc%2Fmockmailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscriptollc%2Fmockmailer/lists"}