{"name":"smtp-server","version":"3.19.6","keywords":["SMTP"],"author":{"name":"Andris Reinman"},"license":"MIT-0","_id":"smtp-server@3.19.6","maintainers":[{"name":"andris","email":"andris@kreata.ee"}],"homepage":"https://github.com/nodemailer/smtp-server#readme","bugs":{"url":"https://github.com/nodemailer/smtp-server/issues"},"dist":{"shasum":"8cf66b3fcb6c9a53210811be923c676499ef9455","tarball":"http://registry-npm.ywwl.com/smtp-server/download/smtp-server-3.19.6.tgz","fileCount":33,"integrity":"sha512-MNMn5u3UFYYh87/pd0ffv6wHpU0hzCIEPFcsZ8KFYLysjf4DxWfll0PrV1KtidROdehlPA/5HvIBEmlH9hjE7A==","signatures":[{"sig":"MEQCID6a3P+y1ZLsqvnWJuW0MWo4CMCuZOr1oNHJ45OY4bwsAiAbNrb+5B7dm/JRImrTcN6Kd3MBBEKN3X6fOM9uYHOLRw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"sig":"MEUCIQCEzcev+4kNFd7zw8s56a6AZaZsGSFsOGHPHRpFf7OahQIgaZfSJueI0j8ecb7YgFWb/Uf0azdGGiO5C4p/CRKWk2Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/smtp-server@3.19.6","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":337394,"size":64794,"noattachment":false,"key":"/smtp-server/-/smtp-server-3.19.6.tgz"},"main":"lib/smtp-server.js","engines":{"node":">=18.18.0"},"gitHead":"11cc4a415db2dd123a431905af448d8f1bb62348","scripts":{"test":"grunt","format":"prettier --write \"**/*.{js,json,md}\"","update":"rm -rf node_modules package-lock.json && ncu -u && npm install"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:82297813-5a84-4b0d-a3f7-bfdc30a22cf0"}},"repository":{"url":"git://github.com/nodemailer/smtp-server.git","type":"git"},"_npmVersion":"11.17.0","description":"Create custom SMTP servers on the fly","directories":{},"_nodeVersion":"24.19.0","dependencies":{"nodemailer":"9.1.1","punycode.js":"2.3.1","ipv6-normalize":"1.0.1"},"_hasShrinkwrap":false,"devDependencies":{"pem":"1.14.8","chai":"4.4.1","grunt":"1.6.3","mocha":"10.7.3","eslint":"10.9.1","prettier":"3.9.6","grunt-cli":"1.5.0","grunt-eslint":"27.0.0","grunt-mocha-test":"0.13.3","eslint-config-prettier":"10.1.8","eslint-config-nodemailer":"1.2.0"},"_npmOperationalInternal":{"tmp":"tmp/smtp-server_3.19.6_1788288891793_0.939274808464809","host":"s3://npm-registry-packages-npm-production"},"readme":"# smtp-server\n\n![Nodemailer](https://raw.githubusercontent.com/nodemailer/nodemailer/master/assets/nm_logo_200x136.png)\n\nNode.JS module for creating SMTP and LMTP server instances on the fly.\n\nSee [smtp-server homepage](https://nodemailer.com/extras/smtp-server/) for documentation and terms.\n\n## Installation and module formats\n\n```\nnpm install smtp-server\n```\n\nThe package ships both an ES module build and a CommonJS build, with TypeScript type declarations for both, so there is no need for `@types/smtp-server` anymore. Use whichever module format your application uses:\n\n```js\n// ES modules\nimport { SMTPServer } from 'smtp-server';\n\n// CommonJS\nconst { SMTPServer } = require('smtp-server');\n```\n\nThe `smtp-server/lib/*` deep imports (for example `require('smtp-server/lib/smtp-connection')`) keep working as well. In TypeScript the public types, such as `SMTPServerOptions`, `SMTPServerSession`, `SMTPServerAddress` and `SMTPServerDataStream`, are exported from the package root.\n\n## Using the SIZE extension\n\nSet the `size` option to advertise a maximum message size to clients. Declared sizes in `MAIL FROM:<addr> SIZE=nnn` parameters are checked against the limit, but by default the actual transfer size is not enforced by the server itself. Message data is streamed to the application, so it is up to the application to decide what to do with an oversized message (or to set `rejectOversized`, see below). Check `stream.sizeExceeded` in your `onData` handler to detect oversized messages:\n\n```js\nconst server = new SMTPServer({\n    size: 1024 * 1024, // 1 MiB limit\n    onData(stream, session, callback) {\n        stream.on('end', () => {\n            if (stream.sizeExceeded) {\n                const err = new Error('Message too large');\n                err.responseCode = 552;\n                return callback(err);\n            }\n            callback(null, 'OK');\n        });\n        stream.resume(); // Consume the stream\n    }\n});\n```\n\nThe `sizeExceeded` flag and the `byteLength` byte counter on the data stream are updated in real time while the message is being received, so a handler that wants to stop an oversized transfer early can also check the flag from a `data` event instead of waiting for `end`.\n\nTo have the server refuse oversized messages itself, set `rejectOversized: true`. A message that went over the `size` limit is then answered with `552 Error: message exceeds fixed maximum message size` (enhanced status code `5.3.4`, one reply per recipient with LMTP), whatever the `onData` callback reports. `onData` still receives the whole stream and still has to consume it. The option defaults to `false` and has no effect without `size`; it also applies when the limit is hidden with `hideSize`.\n\n```js\nconst server = new SMTPServer({\n    size: 1024 * 1024,\n    rejectOversized: true,\n    onData(stream, session, callback) {\n        stream.pipe(storage);\n        stream.on('end', () => callback(null, 'OK')); // a 552 replaces this reply if the message was too large\n    }\n});\n```\n\n## Trusting XCLIENT and XFORWARD\n\nThe `useXClient` and `useXForward` options enable the Postfix [XCLIENT](http://www.postfix.org/XCLIENT_README.html) and [XFORWARD](http://www.postfix.org/XFORWARD_README.html) commands, which let an SMTP proxy pass on the connection details (and, with `XCLIENT LOGIN`, the identity) of the client it is relaying. Anyone allowed to use them can impersonate any client address, so the commands should only be available to the proxies themselves. Set the option to `true` to allow every connecting client, or to an array of the IP addresses the proxies connect from. The address is compared with the one the connection was accepted from (the address from the PROXY protocol header when `useProxy` is used), and IPv4-mapped IPv6 addresses match their IPv4 form, so `['10.0.0.5']` also covers a client that a dual-stack listener reports as `::ffff:10.0.0.5`.\n\n```js\nconst server = new SMTPServer({\n    useXClient: ['10.0.0.5', '10.0.0.6'], // only these hosts may send XCLIENT\n    useXForward: ['10.0.0.5', '10.0.0.6']\n});\n```\n\nOther clients do not see the commands in the EHLO response and get a `550` reply if they try them anyway. `useProxy` takes the same `true` or array value for the PROXY protocol header.\n\n## Disabling commands per session\n\nThe `disabledCommands` option applies to every connection. To decide per connection, set `session.disabledCommands` to an array of command names in `onConnect` (or any later handler). When it is set, it replaces the server wide list for that session, both for the commands the client may use and for the EHLO capability list, so for example `AUTH` and `STARTTLS` are not advertised when the session disables them. Command names are case insensitive, and setting the property back to `undefined` returns the session to the server wide list. Changing `server.options.disabledCommands` from a handler instead affects every open connection.\n\n```js\nconst server = new SMTPServer({\n    disabledCommands: ['AUTH'],\n    onConnect(session, callback) {\n        if (isTrustedNetwork(session.remoteAddress)) {\n            session.disabledCommands = []; // offer AUTH to this client only\n        }\n        callback();\n    }\n});\n```\n\n## Limiting the number of recipients\n\nBy default a mail transaction can have any number of recipients. Set `maxRecipients` to cap the count. Once the limit is reached, further `RCPT TO` commands are answered with `452 Error: too many recipients` (enhanced status code `4.5.3`) as RFC 5321 section 4.5.3.1.10 prescribes, and the client can continue to `DATA` with the recipients that were accepted. A recipient that was already accepted does not count again.\n\n```js\nconst server = new SMTPServer({\n    maxRecipients: 100\n});\n```\n","publish_time":1788288891940,"_cnpm_publish_time":1788288891940,"dist-tags":{"beta":"1.9.0-beta.0","latest":"3.21.3"}}