From 75e3aa33e6ddd8307ffae79ea374b9d11c9a0297 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 18:19:48 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 17 +++++-- package.json | 13 +++++- readme.hints.md | 1 + readme.md | 122 +++++++++++++++++++++++++++++++++++++----------- 4 files changed, 122 insertions(+), 31 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 16e6d99..db84562 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,28 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartsmtp", - "description": "a module for handling smtp stuff", + "description": "A module for handling SMTP operations such as sending emails via SMTP or sendmail transport.", "npmPackagename": "@push.rocks/smartsmtp", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "SMTP", + "email", + "nodemailer", + "sendmail", + "smartmail integration", + "TypeScript", + "email sending", + "email templates", + "programming" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 4a5f4c0..79b3de5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartsmtp", "version": "3.0.3", "private": false, - "description": "a module for handling smtp stuff", + "description": "A module for handling SMTP operations such as sending emails via SMTP or sendmail transport.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -39,5 +39,16 @@ "cli.js", "npmextra.json", "readme.md" + ], + "keywords": [ + "SMTP", + "email", + "nodemailer", + "sendmail", + "smartmail integration", + "TypeScript", + "email sending", + "email templates", + "programming" ] } \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index b5a1044..43a76b6 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,107 @@ -# @pushrocks/smartsmtp +# @push.rocks/smartsmtp a module for handling smtp stuff -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartsmtp) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartsmtp) -* [github.com (source mirror)](https://github.com/pushrocks/smartsmtp) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartsmtp/) +## Install -## Status for master +To install `@push.rocks/smartsmtp`, use the following command with npm: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartsmtp/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartsmtp/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartsmtp)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartsmtp)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartsmtp)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartsmtp)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartsmtp)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +```bash +npm install @push.rocks/smartsmtp --save +``` + +Ensure that you are installing the package in a project set up with TypeScript and support for ECMAScript modules, as the usage examples provided will rely on this configuration. ## Usage -Use TypeScript for best in class intellisense +`@push.rocks/smartsmtp` simplifies handling SMTP-based emailing in Node.js applications, offering a streamlined interface to create transporters and send emails using popular services like Nodemailer and enhancements for template-based emails via `@pushrocks/smartmail`. This guide walks you through setting up a `Smartsmtp` instance and sending emails. -## Contribution +### Setting Up -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +First, ensure you import the necessary classes from the module. Here's how you set up your imports using ESM syntax: -For further information read the linked docs at the top of this readme. +```typescript +import { Smartsmtp } from '@push.rocks/smartsmtp'; +``` -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +### Creating SMTP Transport -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +`@push.rocks/smartsmtp` provides two primary ways to set up an SMTP transporter: through direct SMTP server credentials or utilizing the local `sendmail` command. + +#### SMTP Server Credentials + +To connect to an SMTP server directly, you'll need the server address, username, and password. Here's how you can create a `Smartsmtp` instance using SMTP server credentials: + +```typescript +// Define your SMTP configuration +const smtpOptions = { + smtpServer: 'smtp.example.com', + smtpUser: 'user@example.com', + smtpPassword: 'yourPassword' +}; + +// Async function to create and use a Smartsmtp instance +async function setupSmtp() { + const smtpInstance = await Smartsmtp.createSmartsmtpWithRelay(smtpOptions); + + // smtpInstance is now ready to use +} +``` + +#### Using Sendmail + +If you wish to use the local `sendmail` command, which is common in UNIX environments, you can create a `Smartsmtp` instance dedicated to that: + +```typescript +async function setupSendmail() { + const sendmailInstance = await Smartsmtp.createSmartsmtpSendmail(); + + // sendmailInstance is now ready to use for sending emails +} +``` + +### Sending Emails + +With a `Smartsmtp` instance ready, you can send emails. This requires creating a `Smartmail` instance (from the `@pushrocks/smartmail` package) that defines the email configuration, including subjects, recipients, and body content. + +```typescript +import { Smartmail } from '@pushrocks/smartmail'; + +async function sendEmail(smtpInstance: Smartsmtp) { + // Create a Smartmail instance + const myEmail = new Smartmail({ + from: 'me@example.com', + subject: 'Test Email', + body: 'This is a test email sent using @push.rocks/smartsmtp.' + }); + + // Use the smtpInstance to send the email + const result = await smtpInstance.sendSmartMail(myEmail, 'recipient@example.com'); + + console.log(result); // Check the result +} +``` + +In the example above, `Smartmail` is utilized to define the base content of the email being sent. The `sendSmartMail` method of `Smartsmtp` takes this email configuration, alongside recipient details, and performs the sending operation. + +This completes the basic usage guide for `@push.rocks/smartsmtp`. With these steps, you can integrate straightforward SMTP email sending capabilities into your Node.js applications, leveraging modern TypeScript syntax and ESM modules. For further customization and advanced features, refer to the documentation of Nodemailer and `@pushrocks/smartmail`. + + + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.