First Commit
This commit is contained in:
31
html/sternwarte/checkfuehrung/node_modules/sendmail/.github/CONTRIBUTING.md
generated
vendored
Executable file
31
html/sternwarte/checkfuehrung/node_modules/sendmail/.github/CONTRIBUTING.md
generated
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
# Contributing
|
||||
|
||||
## How to contribute
|
||||
|
||||
Support and contributions from the open source community are essential for keeping
|
||||
Sendmail up to date. We are always looking for the quality contributions and
|
||||
will be happy to accept your Pull Requests
|
||||
|
||||
## Creating an Issue
|
||||
|
||||
Before you create a new Issue:
|
||||
* Check the [Issues](https://github.com/guileen/node-sendmail/issues) on Github to ensure one doesn't already exist.
|
||||
* use one of these topics in the beginning of your issue title- Contrib, Hotfix, Error, Help or Feature.
|
||||
* Clearly describe the issue, including the steps to reproduce the issue.
|
||||
* If it's a new feature, enhancement, or restructure, Explain your reasoning on why you think it should be added, as well as a particular use case.
|
||||
|
||||
## Making Changes
|
||||
|
||||
* Create a topic branch from the development branch with the issue number EX. `#200_make_changes`
|
||||
* Keep git commit messages clear and appropriate
|
||||
* Make Sure you have added any tests necessary to test your code. `npm test` (once testing is added)
|
||||
* Update the Documentation to go along with any changes in functionality / improvements.
|
||||
|
||||
## Submitting the Pull Request
|
||||
|
||||
* Push your changes to your topic branch on your fork of the repo.
|
||||
* Submit a pull request from your topic branch to the development branch
|
||||
* We use [GitFlow](https://guides.github.com/introduction/flow/)
|
||||
* Be sure to tag any issues your pull request is taking care of / contributing to. EX. `#201 add and updated this`
|
||||
* By adding "Closes #xyz" to a commit message will auto close the issue once the pull request is merged in.
|
||||
|
||||
32
html/sternwarte/checkfuehrung/node_modules/sendmail/.github/ISSUE_TEMPLATE.md
generated
vendored
Executable file
32
html/sternwarte/checkfuehrung/node_modules/sendmail/.github/ISSUE_TEMPLATE.md
generated
vendored
Executable file
@@ -0,0 +1,32 @@
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
|
||||
## Expected Behavior
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
<!--- If you're suggesting a change/improvement, tell us how it should work -->
|
||||
|
||||
## Current Behavior
|
||||
<!--- If describing a bug, tell us what happens instead of the expected behavior -->
|
||||
<!--- If suggesting a change/improvement, explain the difference from current behavior -->
|
||||
|
||||
## Possible Solution
|
||||
<!--- Not obligatory, but suggest a fix/reason for the bug, -->
|
||||
<!--- or ideas how to implement the addition or change -->
|
||||
|
||||
## Steps to Reproduce (for bugs)
|
||||
<!--- Provide a link to a live example, or an unambiguous set of steps to -->
|
||||
<!--- reproduce this bug. Include code to reproduce, if relevant -->
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
4.
|
||||
|
||||
## Context
|
||||
<!--- How has this issue affected you? What are you trying to accomplish? -->
|
||||
<!--- Providing context helps us come up with a solution that is most useful in the real world -->
|
||||
|
||||
## Your Environment
|
||||
<!--- Include as many relevant details about the environment you experienced the bug in -->
|
||||
* Version used:
|
||||
* Environment name and version (e.g. Chrome 39, node.js 5.4):
|
||||
* Operating System and version (desktop or mobile):
|
||||
* Link to your project:
|
||||
31
html/sternwarte/checkfuehrung/node_modules/sendmail/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Executable file
31
html/sternwarte/checkfuehrung/node_modules/sendmail/.github/PULL_REQUEST_TEMPLATE.md
generated
vendored
Executable file
@@ -0,0 +1,31 @@
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Motivation and Context
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
<!--- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
## How Has This Been Tested?
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
<!--- see how your change affects other areas of the code, etc. -->
|
||||
|
||||
## Screenshots (if appropriate):
|
||||
|
||||
## Types of changes
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist:
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] My change requires a change to the documentation.
|
||||
- [ ] I have updated the documentation accordingly.
|
||||
- [ ] I have read the **CONTRIBUTING** document.
|
||||
- [ ] I have added tests to cover my changes.
|
||||
- [ ] All new and existing tests passed.
|
||||
23
html/sternwarte/checkfuehrung/node_modules/sendmail/LICENSE
generated
vendored
Executable file
23
html/sternwarte/checkfuehrung/node_modules/sendmail/LICENSE
generated
vendored
Executable file
@@ -0,0 +1,23 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 -2017 Guileen
|
||||
Copyright (c) 2016 -2018 Green Pioneer
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
172
html/sternwarte/checkfuehrung/node_modules/sendmail/Readme.md
generated
vendored
Executable file
172
html/sternwarte/checkfuehrung/node_modules/sendmail/Readme.md
generated
vendored
Executable file
@@ -0,0 +1,172 @@
|
||||
[![npm][npm-image]][npm-url]
|
||||
[![downloads][downloads-image]][downloads-url]
|
||||
[![npm-issues][npm-issues-image]][npm-issues-url]
|
||||
[![js-standard-style][standard-image]][standard-url]
|
||||
|
||||
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
|
||||
[standard-url]: http://standardjs.com/
|
||||
[npm-image]: https://img.shields.io/npm/v/sendmail.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/sendmail
|
||||
[downloads-image]: https://img.shields.io/npm/dt/sendmail.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/sendmail
|
||||
[npm-issues-image]: https://img.shields.io/github/issues/guileen/node-sendmail.svg
|
||||
[npm-issues-url]: https://github.com/guileen/node-sendmail/issues
|
||||
# node-sendmail
|
||||
|
||||
Send mail without SMTP server
|
||||
|
||||
If your interested in helping out this repo please check out the roadmap below to see if anything interests you
|
||||
|
||||
## Roadmap
|
||||
|
||||
* Add Testing
|
||||
* Add Better Error Handling
|
||||
* Add A Retry feature
|
||||
* Update how we do options
|
||||
* Respond with documented status codes
|
||||
* CRLF
|
||||
* replyTo
|
||||
* returnTo
|
||||
* Please submit your ideas as PR's
|
||||
|
||||
## Install
|
||||
|
||||
``` bash
|
||||
npm install sendmail --save
|
||||
# or
|
||||
yarn add sendmail
|
||||
```
|
||||
|
||||
## Options
|
||||
|
||||
``` javascript
|
||||
const sendmail = require('sendmail')({
|
||||
logger: {
|
||||
debug: console.log,
|
||||
info: console.info,
|
||||
warn: console.warn,
|
||||
error: console.error
|
||||
},
|
||||
silent: false,
|
||||
dkim: { // Default: False
|
||||
privateKey: fs.readFileSync('./dkim-private.pem', 'utf8'),
|
||||
keySelector: 'mydomainkey'
|
||||
},
|
||||
devPort: 1025, // Default: False
|
||||
devHost: 'localhost', // Default: localhost
|
||||
smtpPort: 2525, // Default: 25
|
||||
smtpHost: 'localhost' // Default: -1 - extra smtp host after resolveMX
|
||||
})
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
``` javascript
|
||||
const sendmail = require('sendmail')();
|
||||
|
||||
sendmail({
|
||||
from: 'no-reply@yourdomain.com',
|
||||
to: 'test@qq.com, test@sohu.com, test@163.com ',
|
||||
subject: 'test sendmail',
|
||||
html: 'Mail of test sendmail ',
|
||||
}, function(err, reply) {
|
||||
console.log(err && err.stack);
|
||||
console.dir(reply);
|
||||
});
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Please checkout our great examples
|
||||
|
||||
- **[attachmentFile.js](https://github.com/guileen/node-sendmail/blob/master/examples/attachmentFile.js)**
|
||||
- **[developmentMode.js](https://github.com/guileen/node-sendmail/blob/master/examples/developmentMode.js)**
|
||||
- **[dkim.js](https://github.com/guileen/node-sendmail/blob/master/examples/dkim.js)**
|
||||
- **[meetingRequest.js](https://github.com/guileen/node-sendmail/blob/master/examples/meetingRequest.js)**
|
||||
- **[simple.js](https://github.com/guileen/node-sendmail/blob/master/examples/simple.js)**
|
||||
- **[devHostPort.js](https://github.com/guileen/node-sendmail/blob/master/examples/devHostPort.js)**
|
||||
- **[smtpPort.js](https://github.com/guileen/node-sendmail/blob/master/examples/smtpPort.js)**
|
||||
|
||||
## Upgrading
|
||||
|
||||
Note if you were on any previous version before `<1.0.0` You will need to start using `html` instead of `content`. Instead of creating emails ourselves anymore we have decided to use `mailcomposer` to compose our emails. Which means we can give you the same great package with the best mail composer package out there.
|
||||
|
||||
In 1.2.0 "Converted to ES2015" which will break node 4.x
|
||||
|
||||
## Mail Options
|
||||
|
||||
Note we use `mailcomposer` to compose our mail before we send it out so all mail options will be well documented [Here](https://github.com/nodemailer/mailcomposer). But for those who want something particular go ahead and search down below.
|
||||
|
||||
### E-mail message fields
|
||||
|
||||
Below are a list of the most used options for email fields. Please read the entire list of options here [Here](https://github.com/nodemailer/mailcomposer#e-mail-message-fields):
|
||||
|
||||
- **from**
|
||||
- **sender**
|
||||
- **to**
|
||||
- **cc**
|
||||
- **bcc**
|
||||
- **replyTo**
|
||||
- **inReplyTo**
|
||||
- **subject**
|
||||
- **text**
|
||||
- **html**
|
||||
|
||||
### Attachments
|
||||
|
||||
You are also able to send attachents. Please review the list of properties here [Here](https://github.com/nodemailer/mailcomposer#attachments)
|
||||
|
||||
### Alternatives
|
||||
|
||||
In addition to text and HTML, any kind of data can be inserted as an alternative content of the main body. Please check that out [Here](https://github.com/nodemailer/mailcomposer#alternatives)
|
||||
|
||||
### Address Formatting
|
||||
|
||||
All e-mail addresses can be formatted. Please check that out [Here](https://github.com/nodemailer/mailcomposer#address-formatting)
|
||||
|
||||
### SMTP envelope
|
||||
|
||||
SMTP envelope is usually auto generated from `from`, `to`, `cc` and `bcc` fields but you can change them [Here](https://github.com/nodemailer/mailcomposer#smtp-envelope)
|
||||
|
||||
### Using Embedded Images
|
||||
|
||||
Attachments can be used as embedded images in the HTML body. To use this feature, you need to set additional properties [Here](https://github.com/nodemailer/mailcomposer#using-embedded-images)
|
||||
|
||||
## Change Log
|
||||
|
||||
### 1.0.0 Mail Composer
|
||||
|
||||
A better way to compose the emails while still sending them out in the exact same way.
|
||||
|
||||
### 1.1.0 Support for development SMTP
|
||||
|
||||
A property describing a port for a local SMTP server (see [MailHog](https://github.com/mailhog/MailHog)) was added. If the property is omitted, sendmail behaves like it used to. This feature makes it possible to test an application offline and for multiple email addresses without needing to create hundreds of mail accounts. - Special thanks goes out to gumannp for [PR 21](https://github.com/guileen/node-sendmail/pull/21)
|
||||
|
||||
### 1.1.0 Add DKIM signing
|
||||
|
||||
Added a `dkim` object to options that can have two properties: `privateKey` and `keySelector`. These options correspond to the options for [`dkim-signer`](https://github.com/andris9/dkim-signer). Added an example for these options. Special thanks goes out to download13 for [PR 23](https://github.com/guileen/node-sendmail/pull/23)
|
||||
|
||||
### 1.1.1 Readme fix
|
||||
|
||||
simple link and text updates
|
||||
|
||||
### 1.2.0 Added Support for devHost & devPort
|
||||
|
||||
Add option to override "localhost" when sending all SMTP traffic to a dummy server & "Converted to ES2015"
|
||||
|
||||
### 1.3.0
|
||||
|
||||
Add option to override "smtpPort:25"
|
||||
|
||||
### 1.4.0
|
||||
|
||||
Add option to add extra smtp host after resolveMX "smtpHost:-1"
|
||||
Added Yarn Lock
|
||||
|
||||
### 1.4.1
|
||||
|
||||
Update Readme
|
||||
|
||||
## Questions, Comments & Concerns
|
||||
|
||||
Please reach out to [Green Pioneer](https://github.com/greenpioneer). [Guileen](https://github.com/guileen) is the original creator.
|
||||
82
html/sternwarte/checkfuehrung/node_modules/sendmail/package.json
generated
vendored
Executable file
82
html/sternwarte/checkfuehrung/node_modules/sendmail/package.json
generated
vendored
Executable file
@@ -0,0 +1,82 @@
|
||||
{
|
||||
"_from": "sendmail",
|
||||
"_id": "sendmail@1.4.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-MfprntdcmRUlxZJisAJGb4sp8kL4biCbrmcLT9FJsECDATTn3Q1rYkxXyT+DFZ5fIZ5ZPJt+H/eHWUFd1xWUuw==",
|
||||
"_location": "/sendmail",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "tag",
|
||||
"registry": true,
|
||||
"raw": "sendmail",
|
||||
"name": "sendmail",
|
||||
"escapedName": "sendmail",
|
||||
"rawSpec": "",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "latest"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"#USER",
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/sendmail/-/sendmail-1.4.1.tgz",
|
||||
"_shasum": "e0732447f5ff07270fbcecd6030d748bcb4a03cb",
|
||||
"_spec": "sendmail",
|
||||
"_where": "/Users/rxf/Projekte/SternDBase/sternwarte/checkfuehrung",
|
||||
"author": {
|
||||
"name": "Gui Lin",
|
||||
"email": "guileen@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/guileen/node-sendmail/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Gui Lin",
|
||||
"email": "guileen@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Green Pioneer",
|
||||
"email": "info@greenpioneersolutions.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"dkim-signer": "^0.2.2",
|
||||
"mailcomposer": "^3.12.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Sendmail without setting up SMTP server",
|
||||
"devDependencies": {
|
||||
"ical-toolkit": "^1.0.9",
|
||||
"standard": "latest"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
},
|
||||
"homepage": "https://github.com/guileen/node-sendmail",
|
||||
"keywords": [
|
||||
"email sender",
|
||||
"send mail",
|
||||
"sendmail",
|
||||
"node sendmail",
|
||||
"no smtp",
|
||||
"without server",
|
||||
"without smtp server",
|
||||
"dev mode",
|
||||
"dkim sign mail"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./sendmail",
|
||||
"name": "sendmail",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/guileen/node-sendmail.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "standard",
|
||||
"lint:fix": "standard --fix",
|
||||
"test": "npm run lint"
|
||||
},
|
||||
"version": "1.4.1"
|
||||
}
|
||||
327
html/sternwarte/checkfuehrung/node_modules/sendmail/sendmail.js
generated
vendored
Executable file
327
html/sternwarte/checkfuehrung/node_modules/sendmail/sendmail.js
generated
vendored
Executable file
@@ -0,0 +1,327 @@
|
||||
const {createConnection} = require('net');
|
||||
const {resolveMx} = require('dns');
|
||||
const {DKIMSign} = require('dkim-signer');
|
||||
const CRLF = '\r\n';
|
||||
|
||||
function dummy () {}
|
||||
module.exports = function (options) {
|
||||
options = options || {};
|
||||
const logger = options.logger || (options.silent && {
|
||||
debug: dummy,
|
||||
info: dummy,
|
||||
warn: dummy,
|
||||
error: dummy
|
||||
} || {
|
||||
debug: console.log,
|
||||
info: console.info,
|
||||
warn: console.warn,
|
||||
error: console.error
|
||||
});
|
||||
const dkimPrivateKey = (options.dkim || {}).privateKey;
|
||||
const dkimKeySelector = (options.dkim || {}).keySelector || 'dkim';
|
||||
const devPort = options.devPort || -1;
|
||||
const devHost = options.devHost || 'localhost';
|
||||
const smtpPort = options.smtpPort || 25
|
||||
const smtpHost = options.smtpHost || -1
|
||||
/*
|
||||
* 邮件服务返回代码含义 Mail service return code Meaning
|
||||
* 500 格式错误,命令不可识别(此错误也包括命令行过长)format error, command unrecognized (This error also includes command line too long)
|
||||
* 501 参数格式错误 parameter format error
|
||||
* 502 命令不可实现 command can not be achieved
|
||||
* 503 错误的命令序列 Bad sequence of commands
|
||||
* 504 命令参数不可实现 command parameter can not be achieved
|
||||
* 211 系统状态或系统帮助响应 System status, or system help response
|
||||
* 214 帮助信息 help
|
||||
* 220 服务就绪 Services Ready
|
||||
* 221 服务关闭传输信道 Service closing transmission channel
|
||||
* 421 服务未就绪,关闭传输信道(当必须关闭时,此应答可以作为对任何命令的响应)service is not ready to close the transmission channel (when it is necessary to close, this response may be in response to any command)
|
||||
* 250 要求的邮件操作完成 requested mail action completed
|
||||
* 251 用户非本地,将转发向 non-local users will be forwarded to
|
||||
* 450 要求的邮件操作未完成,邮箱不可用(例如,邮箱忙)Mail the required operation 450 unfinished, mailbox unavailable (for example, mailbox busy)
|
||||
* 550 要求的邮件操作未完成,邮箱不可用(例如,邮箱未找到,或不可访问)Mail action not completed the required 550 mailbox unavailable (eg, mailbox not found, no access)
|
||||
* 451 放弃要求的操作;处理过程中出错 waiver operation; processing error
|
||||
* 551 用户非本地,请尝试 non-local user, please try
|
||||
* 452 系统存储不足,要求的操作未执行 Less than 452 storage system, requiring action not taken
|
||||
* 552 过量的存储分配,要求的操作未执行 excess storage allocation requires action not taken
|
||||
* 553 邮箱名不可用,要求的操作未执行(例如邮箱格式错误) mailbox name is not available, that the requested operation is not performed (for example, mailbox format error)
|
||||
* 354 开始邮件输入,以.结束 Start Mail input to. End
|
||||
* 554 操作失败 The operation failed
|
||||
* 535 用户验证失败 User authentication failed
|
||||
* 235 用户验证成功 user authentication is successful
|
||||
* 334 等待用户输入验证信息 waits for the user to enter authentication information
|
||||
*/
|
||||
|
||||
function getHost (email) {
|
||||
const m = /[^@]+@([\w\d\-\.]+)/.exec(email);
|
||||
return m && m[1];
|
||||
}
|
||||
|
||||
function groupRecipients (recipients) {
|
||||
let groups = {};
|
||||
let host;
|
||||
const recipients_length = recipients.length;
|
||||
for (let i = 0; i < recipients_length; i++) {
|
||||
host = getHost(recipients[i]);
|
||||
(groups[host] || (groups[host] = [])).push(recipients[i])
|
||||
}
|
||||
return groups
|
||||
}
|
||||
|
||||
/**
|
||||
* connect to domain by Mx record
|
||||
*/
|
||||
function connectMx (domain, callback) {
|
||||
if (devPort === -1) { // not in development mode -> search the MX
|
||||
resolveMx(domain, function (err, data) {
|
||||
if (err) {
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
data.sort(function (a, b) { return a.priority < b.priority });
|
||||
logger.debug('mx resolved: ', data);
|
||||
|
||||
if (!data || data.length === 0) {
|
||||
return callback(new Error('can not resolve Mx of <' + domain + '>'))
|
||||
}
|
||||
if(smtpHost !== -1)data.push({exchange:smtpHost})
|
||||
function tryConnect (i) {
|
||||
if (i >= data.length) return callback(new Error('can not connect to any SMTP server'));
|
||||
|
||||
const sock = createConnection(smtpPort, data[i].exchange);
|
||||
|
||||
sock.on('error', function (err) {
|
||||
logger.error('Error on connectMx for: ', data[i], err);
|
||||
tryConnect(++i)
|
||||
});
|
||||
|
||||
sock.on('connect', function () {
|
||||
logger.debug('MX connection created: ', data[i].exchange);
|
||||
sock.removeAllListeners('error');
|
||||
callback(null, sock)
|
||||
})
|
||||
}
|
||||
|
||||
tryConnect(0)
|
||||
})
|
||||
} else { // development mode -> connect to the specified devPort on devHost
|
||||
const sock = createConnection(devPort, devHost);
|
||||
|
||||
sock.on('error', function (err) {
|
||||
callback(new Error('Error on connectMx (development) for "'+ devHost +':' + devPort + '": ' + err))
|
||||
});
|
||||
|
||||
sock.on('connect', function () {
|
||||
logger.debug('MX (development) connection created: '+ devHost +':' + devPort);
|
||||
sock.removeAllListeners('error');
|
||||
callback(null, sock)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function sendToSMTP (domain, srcHost, from, recipients, body, cb) {
|
||||
const callback = (typeof cb === 'function') ? cb : function () {};
|
||||
connectMx(domain, function (err, sock) {
|
||||
if (err) {
|
||||
logger.error('error on connectMx', err.stack);
|
||||
return callback(err)
|
||||
}
|
||||
|
||||
function w (s) {
|
||||
logger.debug('send ' + domain + '>' + s);
|
||||
sock.write(s + CRLF)
|
||||
}
|
||||
|
||||
sock.setEncoding('utf8');
|
||||
|
||||
sock.on('data', function (chunk) {
|
||||
data += chunk;
|
||||
parts = data.split(CRLF);
|
||||
const parts_length = parts.length - 1;
|
||||
for (let i = 0, len = parts_length; i < len; i++) {
|
||||
onLine(parts[i])
|
||||
}
|
||||
data = parts[parts.length - 1]
|
||||
});
|
||||
|
||||
sock.on('error', function (err) {
|
||||
logger.error('fail to connect ' + domain)
|
||||
callback(err)
|
||||
});
|
||||
|
||||
let data = '';
|
||||
let step = 0;
|
||||
let loginStep = 0;
|
||||
const queue = [];
|
||||
const login = [];
|
||||
let parts;
|
||||
let cmd;
|
||||
|
||||
/*
|
||||
if(mail.user && mail.pass){
|
||||
queue.push('AUTH LOGIN');
|
||||
login.push(new Buffer(mail.user).toString("base64"));
|
||||
login.push(new Buffer(mail.pass).toString("base64"));
|
||||
}
|
||||
*/
|
||||
|
||||
queue.push('MAIL FROM:<' + from + '>');
|
||||
const recipients_length = recipients.length;
|
||||
for (let i = 0; i < recipients_length; i++) {
|
||||
queue.push('RCPT TO:<' + recipients[i] + '>')
|
||||
}
|
||||
queue.push('DATA');
|
||||
queue.push('QUIT');
|
||||
queue.push('');
|
||||
|
||||
function response (code, msg) {
|
||||
switch (code) {
|
||||
case 220:
|
||||
//* 220 on server ready
|
||||
//* 220 服务就绪
|
||||
if (/\besmtp\b/i.test(msg)) {
|
||||
// TODO: determin AUTH type; auth login, auth crm-md5, auth plain
|
||||
cmd = 'EHLO'
|
||||
} else {
|
||||
cmd = 'HELO'
|
||||
}
|
||||
w(cmd + ' ' + srcHost);
|
||||
break;
|
||||
|
||||
case 221: // bye
|
||||
case 235: // verify ok
|
||||
case 250: // operation OK
|
||||
case 251: // foward
|
||||
if (step === queue.length - 1) {
|
||||
logger.info('OK:', code, msg);
|
||||
callback(null, msg)
|
||||
}
|
||||
w(queue[step]);
|
||||
step++;
|
||||
break;
|
||||
|
||||
case 354: // start input end with . (dot)
|
||||
logger.info('sending mail', body);
|
||||
w(body);
|
||||
w('');
|
||||
w('.');
|
||||
break;
|
||||
|
||||
case 334: // input login
|
||||
w(login[loginStep]);
|
||||
loginStep++;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (code >= 400) {
|
||||
logger.warn('SMTP responds error code', code);
|
||||
callback(new Error('SMTP code:' + code + ' msg:' + msg));
|
||||
sock.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let msg = '';
|
||||
|
||||
function onLine (line) {
|
||||
logger.debug('recv ' + domain + '>' + line);
|
||||
|
||||
msg += (line + CRLF);
|
||||
|
||||
if (line[3] === ' ') {
|
||||
// 250-information dash is not complete.
|
||||
// 250 OK. space is complete.
|
||||
response(parseInt(line), msg);
|
||||
msg = '';
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getAddress (address) {
|
||||
return address.replace(/^.+</, '').replace(/>\s*$/, '').trim();
|
||||
}
|
||||
|
||||
function getAddresses (addresses) {
|
||||
const results = [];
|
||||
if (!Array.isArray(addresses)) {
|
||||
addresses = addresses.split(',');
|
||||
}
|
||||
|
||||
const addresses_length = addresses.length;
|
||||
for (let i = 0; i < addresses_length; i++) {
|
||||
results.push(getAddress(addresses[i]));
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
/**
|
||||
* sendmail directly
|
||||
*
|
||||
* @param mail {object}
|
||||
* from
|
||||
* to
|
||||
* cc
|
||||
* bcc
|
||||
* replyTo
|
||||
* returnTo
|
||||
* subject
|
||||
* type default 'text/plain', 'text/html'
|
||||
* charset default 'utf-8'
|
||||
* encoding default 'base64'
|
||||
* id default timestamp+from
|
||||
* headers object
|
||||
* content
|
||||
* attachments
|
||||
* [{
|
||||
* type
|
||||
* filename
|
||||
* content
|
||||
* }].
|
||||
*
|
||||
* @param callback function(err, domain).
|
||||
*
|
||||
*/
|
||||
function sendmail (mail, callback) {
|
||||
const mailcomposer = require('mailcomposer');
|
||||
const mailMe = mailcomposer(mail);
|
||||
let recipients = [];
|
||||
let groups;
|
||||
let srcHost;
|
||||
if (mail.to) {
|
||||
recipients = recipients.concat(getAddresses(mail.to))
|
||||
}
|
||||
|
||||
if (mail.cc) {
|
||||
recipients = recipients.concat(getAddresses(mail.cc))
|
||||
}
|
||||
|
||||
if (mail.bcc) {
|
||||
recipients = recipients.concat(getAddresses(mail.bcc))
|
||||
}
|
||||
|
||||
groups = groupRecipients(recipients);
|
||||
|
||||
const from = getAddress(mail.from);
|
||||
srcHost = getHost(from);
|
||||
|
||||
mailMe.build(function (err, message) {
|
||||
if (err) {
|
||||
logger.error('Error on creating message : ', err)
|
||||
callback(err, null);
|
||||
return
|
||||
}
|
||||
if (dkimPrivateKey) {
|
||||
const signature = DKIMSign(message, {
|
||||
privateKey: dkimPrivateKey,
|
||||
keySelector: dkimKeySelector,
|
||||
domainName: srcHost
|
||||
});
|
||||
message = signature + '\r\n' + message
|
||||
}
|
||||
for (let domain in groups) {
|
||||
sendToSMTP(domain, srcHost, from, groups[domain], message, callback)
|
||||
}
|
||||
});
|
||||
}
|
||||
return sendmail
|
||||
};
|
||||
1360
html/sternwarte/checkfuehrung/node_modules/sendmail/yarn.lock
generated
vendored
Executable file
1360
html/sternwarte/checkfuehrung/node_modules/sendmail/yarn.lock
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user