-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(validateemail): remove nodemailer and its related dependency
Remove nodemailer and whole validateEmail method from the package and add them to the docs fix #133 Signed-off-by: Niloy Sikdar <niloysikdar30@gmail.com>
- Loading branch information
1 parent
4e51860
commit 7c4ea63
Showing
12 changed files
with
168 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ node_modules/ | |
public/ | ||
build/ | ||
dist/ | ||
docs/ | ||
.docusaurus/ | ||
docs-build/ | ||
CHANGELOG.md | ||
example/lib/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Install Package | ||
|
||
You can install our package using `npm` or `yarn` | ||
|
||
## Using npm | ||
|
||
Enter the following command into your project directory | ||
|
||
```bash | ||
npm install @leopardslab/react-email | ||
``` | ||
|
||
## Using yarn | ||
|
||
You can also use yarn to install the package locally | ||
|
||
```bash | ||
yarn add @leopardslab/react-email | ||
``` | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Install Package | ||
|
||
You can install our package using `npm` or `yarn` | ||
|
||
## Using npm | ||
|
||
Enter the following command into your project directory | ||
|
||
```bash | ||
npm install @leopardslab/react-email | ||
``` | ||
|
||
## Using yarn | ||
|
||
You can also use yarn to install the package locally | ||
|
||
```bash | ||
yarn add @leopardslab/react-email | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
{ | ||
"label": "Usage", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "How to use our package to build responsive email layouts" | ||
} | ||
} | ||
{ | ||
"label": "Usage", | ||
"position": 3, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "How to use our package to build responsive email layouts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Build Layout | ||
|
||
Build simple layouts for Email using our existing components | ||
|
||
## Demo | ||
|
||
Create your Layout at using TypeScript or JavaScript using in React enviroment: | ||
|
||
**In JavaScript** | ||
|
||
```jsx title="Layout.js" | ||
import React from 'react'; | ||
import { Email, Section, Column, Typography } from '@leopardslab/react-email'; | ||
|
||
export default function Layout() { | ||
return ( | ||
<Email> | ||
<Section> | ||
<Column> | ||
<Typography>Hello World</Typography> | ||
</Column> | ||
</Section> | ||
</Email> | ||
); | ||
} | ||
``` | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Build Layout | ||
|
||
Build simple layouts for Email using our existing components | ||
|
||
## Demo | ||
|
||
Create your Layout at using TypeScript or JavaScript using in React enviroment: | ||
|
||
**In JavaScript** | ||
|
||
```jsx title="Layout.js" | ||
import React from 'react'; | ||
import { Email, Section, Column, Typography } from '@leopardslab/react-email'; | ||
|
||
export default function Layout() { | ||
return ( | ||
<Email> | ||
<Section> | ||
<Column> | ||
<Typography>Hello World</Typography> | ||
</Column> | ||
</Section> | ||
</Email> | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"label": "Validation", | ||
"position": 4, | ||
"link": { | ||
"type": "generated-index", | ||
"description": "How to validate your generated email templates" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
--- | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Using Mailtrap | ||
|
||
Validate your generated emails using [Mailtrap](https://mailtrap.io) | ||
|
||
After creating an account on Mailtrap, you can create an inbox and get the SMTP credentials. | ||
|
||
Send the generated emails to the Mailtrap inbox and validate them to check the **spam score, email preview, and other details**. | ||
|
||
Also, you need [nodemailer](https://www.npmjs.com/package/nodemailer) package to send emails. | ||
|
||
```tsx title="usingMailtrap.ts" | ||
import nodemailer from 'nodemailer'; | ||
|
||
interface Auth { | ||
user: string; | ||
pass: string; | ||
} | ||
|
||
export interface MailtrapOptions { | ||
from: string; | ||
to: string; | ||
subject: string; | ||
HTMLEmail: string; | ||
textEmail?: string; | ||
auth: Auth; | ||
} | ||
|
||
export async function validateEmailUsingMailtrap({ | ||
from, | ||
to, | ||
subject, | ||
HTMLEmail, | ||
textEmail, | ||
auth, | ||
}: MailtrapOptions) { | ||
const transporter = nodemailer.createTransport({ | ||
host: 'smtp.mailtrap.io', | ||
port: 2525, | ||
auth: { | ||
user: auth.user, | ||
pass: auth.pass, | ||
}, | ||
}); | ||
|
||
let info, error; | ||
|
||
try { | ||
const res = await transporter.sendMail({ | ||
from: from, | ||
to: to, | ||
subject: subject, | ||
text: textEmail, | ||
html: HTMLEmail, | ||
}); | ||
|
||
info = res; | ||
} catch (err) { | ||
console.log(err); | ||
error = err; | ||
} | ||
|
||
return { info, error }; | ||
} | ||
``` | ||
|
||
Import the `validateEmailUsingMailtrap` function and pass the required parameters. | ||
|
||
```tsx title="index.ts" | ||
import { validateEmailUsingMailtrap } from './usingMailtrap'; | ||
|
||
async function validate() { | ||
const { info, error } = await validateEmailUsingMailtrap({ | ||
from: 'From email address', | ||
to: 'To email address', | ||
subject: 'Test Email', | ||
HTMLEmail: 'Generated HTML email', | ||
textEmail: 'Text version of the email', | ||
auth: { | ||
user: 'Mailtrap username', | ||
pass: 'Mailtrap password', | ||
}, | ||
}); | ||
|
||
if (error) { | ||
console.log(error); | ||
} else { | ||
console.log(info); | ||
} | ||
} | ||
|
||
validate(); | ||
``` | ||
|
||
This will help you to check the spam score and other details of the generated email before sending it to the actual recipients. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters