sendr-client v1.0.1
Sendr Mail API Client
Sendr Mail API Client is a simple and lightweight Node.js SDK for sending and broadcasting emails via the sendr.live API. With this package, you can quickly integrate email-sending functionality into your Node.js applications using a plug-and-play approach.
Features
- Simple Integration: Just plug and play with your API key.
- Send Emails: Send individual or broadcast emails.
- Broadcast Emails: Easily send emails to multiple recipients using a comma-separated list.
- Error Handling: Provides detailed error messages for better debugging.
Installation
Install the SDK via npm:
npm install sendr-client
Getting Started
1. Get an API Key
- Go to sendr.live and create an account.
- Create a Team.
- Generate a new API key within the team.
2. Send Emails
You can send individual emails or broadcast emails by passing a comma-separated list of recipient email addresses.
Here’s an example of how to use the SDK:
const Sendr = require('sendr-client');
(async () => {
try {
const response = await Sendr({
recipients: 'sauviknathref@gmail.com',
subject: 'Test Email',
body: '<h1>Hello, this is a test!</h1>',
apiKey: 'your-api-key-here',
});
console.log('Response:', response);
} catch (error) {
console.error('Error:', error.message);
}
})();
API Reference
Sendr(params)
Parameters:
recipients
(string, required)
A single email address or a comma-separated list of email addresses for broadcast emails.subject
(string, required)
The subject of the email.body
(string, required)
The email body in HTML format.apiKey
(string, required)
Your API key obtained from sendr.live.
Returns:
A Promise
that resolves to the response from the Sendr API.
Example:
const response = await Sendr({
recipients: 'example1@example.com,example2@example.com',
subject: 'Broadcast Email Test',
body: '<p>This is a broadcast email.</p>',
apiKey: 'your-api-key-here',
});
console.log(response);
Error Handling
If the API encounters an error, it throws an error with a detailed message. For example:
Missing required fields:
Error: All parameters (recipients, subject, body, apiKey) are required.
Invalid API key:
Error: API Error: Invalid API key
Network issues or other errors:
Error: Request Error: Network Error
Additional Notes
- Ensure your API key is kept secure and not exposed publicly.
- For optimal performance when broadcasting emails, keep the recipient list size manageable to avoid timeouts.
Support
For issues, feature requests, or contributions, please visit the GitHub repository.
If you encounter API-related issues, contact Sendr Live Support.
License
This project is licensed under the MIT License.