Git Product home page Git Product logo

rodyherrera / node-mailu Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 16 KB

๐Ÿ’Œ A library designed to facilitate interaction with the Mailu API. This library provides methods and functions that allow developers to programmatically manage various operations related to the configuration and administration of email servers through the Mailu API.

Home Page: https://test.mailu.io/api/v1/

License: MIT License

JavaScript 100.00%
mailu api-rest dkim dmarc fetchmail mail mailserver nodejs pop3 rest-client smtp webmail

node-mailu's Introduction

node-mailu

This client library provides a convenient way to interact with a Mailu API instance. It encapsulates the necessary details for authentication and interaction with various Mailu services.

Reference: Mailu's official RestAPI documentation.: https://mailu.io/master/api.html

Installation

You can install node-mailu via npm:

npm install node-mailu

Usage

const axios = require('axios');
const MailuClient = require('node-mailu');

// Replace with your Mailu instance's endpoint and API key
const endpoint = 'https://mailu.yourdomain.com/api/v1';
const apiKey = 'YOUR_API_KEY'; 

const mailuClient = new MailuClient(endpoint, apiKey);

// Example: Creating a new user
(async () => {
    try{
        const user = await mailuClient.userService.createUser({
            email: '[email protected]',
            raw_password: 'yourpassword',
            comment: 'New user account'
        });
        console.log('User created:', user.data);
    }catch(error){
        console.error('Error creating user:', error);
    }
})();
Important Note

Your API key is stored within the mailu directory on your system, contained within the .env environment file. Reference the Mailu documentation for specifics.

Sections

  • MailuClient
    • Constructor
    • useAxios
  • Services
    • AliasService
    • AlternativeService
    • DomainService
    • RelayService
    • UserService

MailuClient

The core client for interacting with the Mailu API.

Constructor

constructor(endpoint, apiKey)
  • endpoint (string): The base URL of your Mailu API instance.
  • apiKey (string): An authorization key to access the Mailu API.

useAxios

A utility method to handle API requests using Axios.

useAxios(method, path, data)
  • method (string): The HTTP method to use ('get', 'post', etc.).
  • path (string): The endpoint path relative to the base URL.
  • data (object, optional): Data to send in the request body.

Returns: A Promise resolving with the API response data, or rejecting with an error.

Services

Each service represents a domain of functionality within the Mailu API.

AliasService

Methods for managing email aliases in Mailu.

  • getAliases() - Retrieves all aliases.
  • createAlias(body) - Creates a new alias.
  • getAliasesFromDomain(domain) - Retrieves aliases for a specific domain.
  • updateAlias(alias, body) - Updates an existing alias.
  • getAlias(alias) - Retrieves a single alias.
  • deleteAlias(alias) - Deletes an alias.

AlternativeService

Methods for managing alternative addresses (additional emails for receiving to a user's inbox).

  • getAlternatives() - Retrieves all alternative addresses.
  • createAlternative(body) - Creates a new alternative address.
  • getAlternative(alt) - Retrieves details of an alternative address.
  • deleteAlternative(alt) - Deletes an alternative address.

DomainService

Methods for managing domains in Mailu.

  • getDomains() - Lists all domains.
  • createDomain(body) - Creates a new domain.
  • updateDomain(domain, body) - Updates a domain.
  • getDomain(domain) - Retrieves details of a domain.
  • deleteDomain(domain) - Deletes a domain.
  • generateDomainKeys(domain) - Generates DKIM keys for a domain.
  • getDomainManagers(domain) - Lists managers for a domain.
  • createDomainManager(domain, body) - Adds a new domain manager.
  • deleteDomainManager(domain, email) - Removes a domain manager.
  • getDomainManager(domain, email) - Retrieves details of a domain manager.
  • getUsersFromDomain(domain) - Lists users of a domain.

RelayService

Methods for managing email relays.

  • getRelays() - Lists all relays.
  • createRelay(body) - Creates a new relay.
  • updateRelay(name, body) - Updates a relay.
  • getRelay(name) - Gets details of a relay.
  • deleteRelay(name) - Deletes a relay.

UserService

Methods for managing Mailu users.

  • getUsers() - Lists all users.
  • createUser(body) - Creates a new user.
  • updateUser(email, body) - Updates a user.
  • getUser(email) - Retrieves details of a user.
  • deleteUser(email) - Deletes a user.

node-mailu's People

Contributors

rodyherrera avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.