# email-verification-code-sendgrid

> Using sendgrid, we added 2 other functions to make the verification more secure and more intense. Now you can confirm with a Token that is generated at the beginning, or confirm with the code and the token at the same time!

Latest version **2.2.0** (published 2021-10-27) · ISC license · 0 weekly downloads

## Install

```sh
npm install email-verification-code-sendgrid
pnpm add email-verification-code-sendgrid
yarn add email-verification-code-sendgrid
bun add email-verification-code-sendgrid
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.0 |
| Published | 2021-10-27 |
| First published | 2021-10-26 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 (+12 in 1 direct dependencies) |
| Install scripts | no |
| Author | Daniel Sifontes |
| Maintainers | sifontesdaniel |
| Keywords | email, verification, email-verification, code, email-confirmation, mailing, sendgrid |

## Links

- npm: https://www.npmjs.com/package/email-verification-code-sendgrid
- npm.io page: https://npm.io/package/email-verification-code-sendgrid

## Dependencies (2)

- [nodemailer](https://npm.io/package/nodemailer.md) ^6.4.16
- [uuid-token-generator](https://npm.io/package/uuid-token-generator.md) ^1.0.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.2.0 (latest) — 2021-10-27
- 2.1.0 — 2021-10-26
- 1.2.0 — 2021-10-26
- 1.1.1 — 2021-10-26
- 1.1.0 — 2021-10-26
- 1.0.0 — 2021-10-26

## README

# Email Verification Code Sendgrid- V2 

## What has changed?

With Sendgrid, We added <strong>2 other functions</strong> to make the verification more secure and more intense.<br>
Now you can confirm with a Token that is generated at the beginning, or confirm with the code and the token at the same time!

## How the changes can be helpful?

With the <strong>Token Code</strong>, you can easily verify the email with a link redirection without restraint!<br>

This package is a fork from <strong>email-verification-code</strong> by <strong>FahDev1@gmail.com</strong>

## Installation

This is a [Node.js](https://nodejs.org/en/) module available through the npm registry.

Installation is done using the [npm install command](https://docs.npmjs.com/downloading-and-installing-packages-locally):

```bash
npm install email-verification-code-sendgrid --save
```

## Usage

```js
const {
  sendCode,
  verifyCode,
  verifyToken,
  verifyBoth,
} = require("email-verification-code-sendgrid");

// Send the code to the User Email.

const data = {
  smtpInfo: {
    host: "0.0.0.0",
    port: 587,
    user: "test@example.com",
    pass: 23454,
  },
  company: {
    name: "danisifon.",
    email: "danisifon@gmail.com",
  },
  mailInfo: {
    emailReceiver: "danireceiv@gmail.com",
    subject: "Code Confirmation",
    text(code) {
      return `The Confirmation Code is: ${code}`;
    },
    html(code) {
      return `<p>The Confirmation Code is: ${code}</p>`;
    },
  },
};

sendCode(data);

// To verify the code validity

const response = verifyCode("example@email.com", 3429921);

// To verify with the Token code

const response = verifyToken("CunedqBnbxT85jbXLrApHh");

// To verify with both codes

const codes = {
  code: 3429921,
  token: "CunedqBnbxT85jbXLrApHh",
};

const response = verifyBoth(codes);

console.log(response);
```

### smtpInfo

| Option | Type   | Default | Description                                                     | Required |
| ------ | ------ | ------- | --------------------------------------------------------------- | -------- |
| host   | String | null    | SMTP HOST, required to Connect to Your SMTP & Send the mail     | True     |
| port   | Number | 587     | SMTP PORT, required to Connect to Your SMTP & Send the mail     | True     |
| user   | String | null    | SMTP User, required to Connect to Your SMTP & Send the mail     | True     |
| pass   | String | null    | SMTP Password, required to Connect to Your SMTP & Send the mail | True     |

### company

| Option | Type   | Default | Description                              | Required                           |
| ------ | ------ | ------- | ---------------------------------------- | ---------------------------------- |
| name   | String | null    | Your company Name, sent in the FROM tag  | false, One of the two is Required. |
| email  | String | null    | Your company email, sent in the from tag | false, One of the two is Required. |

### mailInfo

| Option        | Type     | Default | Description                                                                                                                | Required                           |
| ------------- | -------- | ------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
| emailReceiver | String   | null    | User or Receiver Email                                                                                                     | True                               |
| subject       | String   | null    | The mail Subject                                                                                                           | False                              |
| text          | Function | ''      | The mail content.<br><strong>NB:</strong> This function must have two parameters which corresponds to the Code & the Token | False, One of the two is Required. |
| html          | Function | ''      | The mail content.<br><strong>NB:</strong> This function must have two parameters which corresponds to the Code & the Token | False, One of the two is Required. |

## How it Work!

The script generates a 6-digit & a token codes with 1 hour validity and saves it locally (For security reasons, please call the backend functions) and then sends an email with the message you had inserted previously.

To check the code, all you need to do is have the email address and the code. The script will look for the code in the local database, compare it, delete it if the code is correct, and give you a response to do so.

## License

[MIT](https://choosealicense.com/licenses/mit/)

---
_Source: https://npm.io/package/email-verification-code-sendgrid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
