{"id":19232657,"url":"https://github.com/makeomatic/ms-mailer","last_synced_at":"2025-04-21T04:32:44.601Z","repository":{"id":2039793,"uuid":"45479755","full_name":"makeomatic/ms-mailer","owner":"makeomatic","description":"Simple microservice for sending emails, relies on nodemailer and ms-amqp-transport","archived":false,"fork":false,"pushed_at":"2024-01-20T17:35:54.000Z","size":1572,"stargazers_count":6,"open_issues_count":22,"forks_count":7,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-09-21T13:22:30.860Z","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/makeomatic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2015-11-03T16:32:13.000Z","updated_at":"2021-11-08T09:30:45.000Z","dependencies_parsed_at":"2023-01-13T12:15:15.731Z","dependency_job_id":null,"html_url":"https://github.com/makeomatic/ms-mailer","commit_stats":null,"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-mailer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-mailer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-mailer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/makeomatic%2Fms-mailer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/makeomatic","download_url":"https://codeload.github.com/makeomatic/ms-mailer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223849354,"owners_count":17213640,"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","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-11-09T16:07:06.392Z","updated_at":"2024-11-09T16:07:07.017Z","avatar_url":"https://github.com/makeomatic.png","language":"JavaScript","readme":"# Mailer Microservice\n\nSets up a rabbitmq consumer with QoS, and distributes incoming messages based on passed options\n\n[![npm version](https://badge.fury.io/js/ms-mailer.svg)](https://badge.fury.io/js/ms-mailer)\n[![Build Status](https://semaphoreci.com/api/v1/projects/93fdae46-0b24-4af7-9078-fd369109b906/658194/shields_badge.svg)](https://semaphoreci.com/makeomatic/ms-mailer)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)\n[![codecov.io](https://codecov.io/github/makeomatic/ms-mailer/coverage.svg?branch=master)](https://codecov.io/github/makeomatic/ms-mailer?branch=master)\n\n## Installation\n\n`npm i ms-mailer -S`\n\nCompatible with node \u003e= 7.6.x\n\n## Usage\n\n```js\nconst Promise = require('bluebird');\nconst Mailer = require('ms-mailer');\nconst AMQP = require('@microfleet/transport-amqp');\n\nconst mailer = new Mailer({\n  debug: Boolean,\n  predefinedLimits: {\n    maxConnections: Number,\n    maxMessages: Number,\n  },\n  amqp: {\n    // @microfleet/transport-amqp options\n  },\n  htmlToText: {\n    // https://www.npmjs.com/package/html-to-text\n  },\n  accounts: {\n    test: {\n      // nodemailer smtp transport configuration\n      service: 'yahoo',\n      auth: {\n        user: 'test@yahoo.com',\n        pass: '123'\n      }\n    }\n  }\n});\n\n// returns promise, which resolves when listeners are established\nconst mailerReady = mailer.connect();\n\nPromise.props({ mailer: mailerReady, amqp: AMQP.connect() })\n.then(function sendMessage(props) {\n  const { amqp } = props;\n  return amqp.publishAndWait('mailer.predefined', {\n    account: 'test',\n    email: {\n      // nodemailer mail options\n      // make sure not to pass streams or paths, as they can't be transferred through the wire\n      // as the processing will be held on the other machine\n      // in case you want to use some other services like S3, then an expansion can be coded for this module\n    }\n  });\n})\n.then(function sendMessageReponse(response) {\n  // nodemailer smtp transport response\n});\n\n```\n\n## Configuration options\n\n1. `debug` - boolean, whether to print log messages or not\n2. `prefix` - which route prefix to bind to, defaults to `mailer`\n3. `postfixAdhoc` -  which suffix to use for adhoc messaging\n4. `postfixPredefined` - which suffix to use for predefined accounts messaging\n5. `predefinedLimits` - which opts to pass to smtp transport constructor for predefined accounts, consult nodemailer-smtp-transport\n6. `amqp` - options that are passed to `ms-amqp-transport`\n7. `htmlToText` - html to text conversion options for nodemailer\n8. `accounts` - predefined accounts that are initialized at service startup, format is the same as in the nodemailer smtp transport\n\n## Messaging format\n\n1. Adhoc messaging `mailer.adhoc`:\n\n```js\n{\n  \"account\": String,\n  \"email\": {\n    // nodemailer email payload\n  }\n}\n```\n\n2. Predefined messaging `mailer.predefined`:\n\n```js\n{\n  \"account\": {\n    // nodemailer smtp transport format\n  },\n  \"email\": {\n    // nodemailer email payload\n  }\n}\n```\n\n## Roadmap\n\n1. test dkim signing\n2. test different types of messages being sent\n3. test more error cases\n4. add QoS handling on demand\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakeomatic%2Fms-mailer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmakeomatic%2Fms-mailer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmakeomatic%2Fms-mailer/lists"}