Postkutsche

postkutsche. Postkutsche

Class representing the Postkutsche client

Constructor

new Postkutsche(info)

Source:
Create a postkutsche client.
Example
(async () => {
    //import the process.env variables from the .env file in which you should store them
    //you can install dotenv with `npm i dotenv --save-dev` or `yarn add dotenv --dev`
    require('dotenv').config();

    //import the Postkutsche class
    const {
        Postkutsche
    } = require("./index.js");

    //create a new instance of Postkutsche providing it with the necessary api keys
    const pk = new Postkutsche({
        mailcow: {
            url: process.env.MAILCOW_API_URL,
            apikey: process.env.MAILCOW_API_KEY
        },
        powerdns: {
            url: process.env.PDNS_API_URL,
            apikey: process.env.PDNS_API_KEY
        }
    });

    const info={
        nameserver: ['ns1.domain.tld', 'ns2.domain.tld', 'ns3.domain.tld'],
        hostmasterEmail: 'hostmaster@domain.tld',
        dmarcMail: 'postmaster@domain.tld', 
        mailDomain: 'domain.tld',
        mailServerHostname: 'mail.domain.tld',
        defaultMailbox: {
            local_part: `max.mustermensch`,
            name: `Max Mustermensch`
        },
        //NEEDED FOR MAILSERVER DOMAIN SETUP
        mailServerIp: '2a00:1450:4016:801::2003', //Your IPv6 address WITHOUT brackets([]) 
        mailServerLegacyIp: '127.0.0.1',//Your IPv4 address
        addLetsEncryptCAA: true,
        caaReportMail: 'caa.report@domain.tld' //can be set if you want to get reports on malicious cert issues
    }

    //use a function from the Postkutsche class
    //adds the mail records for a domain and creates the domain on mailcow
    await pk.addMailDomain(info);
})();
Parameters:
Name Type Description
info ApiInfo The provided ApiInfo object

Methods

(async) addMailDomain(info, logopt) → {Boolean}

Source:
This will add: - Mailcow: - Domain (if not present) - Mailbox (if not present) - DKIM Key (if not present) - Alias: catchall (catchall will relay everything @yourdomain.tld to your Mailbox) (if not present) - PowerDns: - Domain (if not present) - Mail records for the domain (won't touch other records but will overwrite present matching records) - DNSSEC (if domain wasn't present) - Create record on mailServerDomain(if not the same as mailDomain) to allow dmarc mails to sent to this domain
Example
await pk.addMailDomain({
            nameserver: ['ns1.domain.tld', 'ns2.domain.tld', 'ns3.domain.tld'],
            hostmasterEmail: 'hostmaster@domain.tld',
            dmarcMail: 'postmaster@domain.tld', 
            mailDomain: 'domain.tld',
            mailServerHostname: 'mail.domain.tld',
            defaultMailbox: {
                local_part: `max.mustermensch`,
                name: `Max Mustermensch`,
                password:`set some good password here` //can be omitted
            }
        });
Parameters:
Name Type Attributes Default Description
info Info Info object with the necessary information to create a mail domain on mailcow and the necessary records on powerdns
log Boolean <optional>
true you can disable logging by setting this to false
Returns:
true on success
Type
Boolean

(async) addMailDomainRecords(info, logopt) → {Boolean}

Source:
This will add: - PowerDns: - Domain (if not present) - Mail records for the domain (won't touch other records but will overwrite present matching records) - DNSSEC (if domain wasn't present) - Create record on mailServerDomain(if not the same as mailDomain) to allow dmarc mails to sent to this domain
Example
await pk.addMailDomainRecords({
            nameserver: ['ns1.domain.tld', 'ns2.domain.tld', 'ns3.domain.tld'],
            hostmasterEmail: 'hostmaster@domain.tld',
            dmarcMail: 'postmaster@domain.tld', 
            mailDomain: 'domain.tld',
            mailServerHostname: 'mail.domain.tld',
            }
        });
Parameters:
Name Type Attributes Default Description
info Info Info object with the necessary information to create a mail domain on mailcow and the necessary records on powerdns
log Boolean <optional>
true you can disable logging by setting this to false
Returns:
true on success
Type
Boolean

(async) addMailServerDnsRecords(info, logopt) → {Boolean}

Source:
This will add: - PowerDns: - Domain for the mailserver hostname (if not present) - DNSSEC (will replace old dnssec if present) - TLSA records for the domain (for the creation of the tlsa records you need to have openssl installed. you can specify the path, if it can't be found globally as 'openssl') - Records for the mailserver
Example
await pk.addMailServerDnsRecords({
            nameserver: ['ns1.domain.tld', 'ns2.domain.tld', 'ns3.domain.tld'],
            hostmasterEmail: 'hostmaster@domain.tld',
            mailServerHostname: 'mail.domain.tld',
            mailServerIp: '2a00:1450:4016:801::2003', //Your IPv6 address WITHOUT brackets([]) 
            mailServerLegacyIp: '127.0.0.1',//Your IPv4 address
            addLetsEncryptCAA: true,
            caaReportMail: 'caa.report@domain.tld' //can be set if you want to get reports on malicious cert issues
    });
Parameters:
Name Type Attributes Default Description
info Info Info object with the necessary information to create the relevant records for the mailserver
log Boolean <optional>
true you can disable logging by setting this to false
Returns:
true on success
Type
Boolean

(async) addTLSARecordsToMailServerDomain(info, logopt) → {Boolean}

Source:
This will add: - PowerDns: - TLSA records for the domain (for the creation of the tlsa records you need to have openssl installed. you can specify the path, if it can't be found globally as 'openssl')
Example
await pk.addTLSARecordsToMailDomain({
            mailDomain: 'domain.tld',
            mailServerHostname: 'mail.domain.tld',

        });
Parameters:
Name Type Attributes Default Description
info Info Info object with the necessary information to create the tlsa records on pdns
log Boolean <optional>
true you can disable logging by setting this to false
Returns:
true on success
Type
Boolean

(async) cleanupAddMailDomain(info)

Source:
Will delete a domain from powerdns and mailcow THIS WILL DELETE YOUR MAILBOX AND EVERYTHING ELSE CONCERNING THIS DOMAIN
Example
await pk.cleanupAddMailDomain({
             dmarcMail: 'postmaster@domain.tld', 
             mailDomain: 'domain.tld',
             defaultMailbox: {
                 local_part: `max.mustermensch`,
                 name: `Max Mustermensch`
             }
         });
Parameters:
Name Type Description
info Info Info object with the necessary information to create a mail domain on mailcow and the necessary records on powerdns

(async) cleanupAddMailServer(info)

Source:
Will delete the complete mailserver domain from powerdns
Example
pk.cleanupAddMailServer({mailServerHostname:'mail.domain.tld'});
Parameters:
Name Type Description
info Info Info object with the necessary information to delete the mailserver domain

genMailDomainRecords(info) → {Array}

Source:
Example
pk.genMailDomainRecords({
            mailServerHostname: 'mail.domain.tld',
            mailDomain: 'domain.tld',
            dmarcMail: 'dmarc@domain.tld'
        });
Parameters:
Name Type Description
info Info Info object with the necessary information to generate the domain mail records
Returns:
with domain relevant mail records
Type
Array

(async) getTLSA(info) → {Array}

Source:
Example
await pk.getTLSA({
            mailServerHostname: 'mail.domain.tld',
            mailServerIp: '2a00:1450:4016:801::2003',
            mailServerLegacyIp: '127.0.0.1'
        });
Parameters:
Name Type Description
info Info Info object with the necessary information to generate the tlsa records
Returns:
with tlsa records ready to be inserted into powerdns
Type
Array

openpgpHash(localPart)

Source:
Creates the front part of the openpgp dns record
Example
console.log(pk.openpgpHash('max.mustermensch'));
Parameters:
Name Type Description
localPart String local part of your email address (the part before the @ not including the @)

openpgpRecord(localPart, publicKeyB64) → {OpenpgpRecord}

Source:
Creates an openpgp dns record
Example
console.log(pk.openpgpRecord('max.mustermensch','-----BEGIN PGP (...)'));
Parameters:
Name Type Description
localPart String local part of your email address (the part before the @ not including the @)
publicKeyB64 String your publickey in base64 (it should be correct if it includes -----BEGIN PGP PUBLICKEY BLOCK-----) or only contains these characters: A-Z a-z 0-9 + /
Returns:
Type
OpenpgpRecord

(async) setOpenpgpRecord(localPart, domain, publicKeyB64)

Source:
Sets an openpgp record on your powerdns server Will overwrite key with the same local part
Example
await pk.setOpenpgpRecord('max.mustermensch','domain.tld','-----BEGIN PGP (...)');
Parameters:
Name Type Description
localPart String local part of your email address (the part before the @ not including the @)
domain String the domain you want to add the key to
publicKeyB64 String your publickey in base64 (it should be correct if it includes -----BEGIN PGP PUBLICKEY BLOCK-----) or only contains these characters: A-Z a-z 0-9 + /