gmailit
v1.0.0
Published
Node.js library for the Gmailit API
Downloads
6
Readme
Gmailit Node.js SDK
Node.js library for the Gmailit API.
Install
npm install gmailit
# or
yarn add gmailit
# or
pnpm add gmailit
Examples
coming soon
Setup
First, you need to get an API key, which is available in the gmailit Dashboard.
import { Gmailit } from 'gmailit';
const gmailit = new Gmailit('re_123456789');
Usage
Send your first email:
await gmailit.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'hello world',
text: 'it works!',
});
Send email using HTML
Send an email custom HTML content:
await gmailit.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'hello world',
html: '<strong>it works!</strong>',
});
Send email using React
Start by creating your email template as a React component.
import React from 'react';
export default function EmailTemplate(props) {
const { firstName, product } = props;
return (
<div>
<h1>Welcome, {firstName}!</h1>
<p>Thanks for trying {product}. We’re thrilled to have you on board.</p>
</div>
);
}
Then import the template component and pass it to the react
property.
import EmailTemplate from '../components/EmailTemplate';
await gmailit.emails.send({
from: '[email protected]',
to: '[email protected]',
subject: 'hello world',
react: <EmailTemplate firstName="John" product="MyApp" />,
});
License
MIT License