
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
mailcow-api
Advanced tools
npm i mailcow-api
(async () => {
//get global variables
require('dotenv').config();
//import the api client module
const {
MailcowApiClient
} = require("mailcow-api")
//create new mailcow api client with endpoint/baseurl and the api key
const mcc = new MailcowApiClient(process.env.MAILCOW_API_BASEURL, process.env.MAILCOW_API_KEY);
//get all domain on mailcow server
console.log(await mcc.getDomain());
})();
The line "require('dotenv').config();" gets the contents of a file called ".env" in which you should store your global and secret variables.
npm i dotenv
.env
MAILCOW_API_KEY='YOUR MAILCOW API KEY'
MAILCOW_API_BASEURL='https://mail.example.com' //no trailing slashes
process.env.MAILCOW_API_BASEURL
process.env.MAILCOW_API_KEY
If not: Do it now! It's easy! For Android you can use the andOTP app. andOTP can be used for 2FA with many services and is way better then the Google Authenticator app.
Feel free to contact me via xl9jthv_7bvgakv9o9wg0jabn2ylm91xxrzzgt0e@y.gy in english or german
Object
For all options check out https://demo.mailcow.email/api/
Object
Object representing a DKIM Key
Object
Object representing a domain admin
Object
Object representing a mailbox
Array.<MailboxAnswer>
Array.<Mailbox>
Array
Boolean
Boolean
Boolean
Boolean
Object
Boolean
Object
Object
Object
Boolean
Boolean
Class representing the Mailcow API client
Kind: static class of mailcow-api
Array.<MailboxAnswer>
Array.<Mailbox>
Array
Boolean
Boolean
Boolean
Boolean
Object
Boolean
Object
Object
Object
Boolean
Boolean
Create a Mailcow API client.
Param | Type | Description |
---|---|---|
baseurl | string | The base url where the api can be found |
apikey | string | The api key for the mailcow api endpoint |
Example
(async () => {
//get global variables
require('dotenv').config();
//import the api client module
const {
MailcowApiClient
} = require("mailcow-api")
//create new mailcow api client with endpoint/baseurl and the api key
const mcc = new MailcowApiClient(process.env.MAILCOW_API_BASEURL, process.env.MAILCOW_API_KEY);
//get all domain on mailcow server
console.log(await mcc.getDomain());
})();
Array.<MailboxAnswer>
Updates Mailboxes See the data structure here: https://demo.mailcow.email/api/#/Mailboxes/Update%20mailbox
Kind: instance property of MailcowApiClient
Param | Type | Description |
---|---|---|
mailboxes | Array.<Mailbox> | mailboxes |
Example
await mcc.updateMailboxes({
"attr": {
"active": "1",
"force_pw_update": "0",
"name": "Full name",
"password": "",
"password2": "",
"quota": "3072",
"sender_acl": [
"default",
"info@domain2.tld",
"domain3.tld",
"*"
],
"sogo_access": "1"
},
"items": [
"info@domain.tld"
]
})
Array.<Mailbox>
Updates Mailboxes
Kind: instance property of MailcowApiClient
Param | Type | Description |
---|---|---|
id | "all" | "user@domain.tld" | "all" or "user@domain.tld" |
Example
const answer=await getMailboxes("all");
answer will be: [
{
"active": "1",
"attributes": {
"force_pw_update": "0",
"mailbox_format": "maildir:",
"quarantine_notification": "never",
"sogo_access": "1",
"tls_enforce_in": "0",
"tls_enforce_out": "0"
},
"domain": "doman3.tld",
"is_relayed": 0,
"local_part": "info",
"max_new_quota": 10737418240,
"messages": 0,
"name": "Full name",
"percent_class": "success",
"percent_in_use": 0,
"quota": 3221225472,
"quota_used": 0,
"rl": false,
"spam_aliases": 0,
"username": "info@doman3.tld"
}
]
Array
Gets a specific domain or all domains
Kind: instance method of MailcowApiClient
Returns: Array
- Array of domains
Param | Type | Default | Description |
---|---|---|---|
[domain] | String | 'all' | The domain you want to get |
Example
await mcc.getDomain()
Boolean
Adds a domain to the server
Kind: instance method of MailcowApiClient
Returns: Boolean
- True on success
Param | Type | Description |
---|---|---|
domain | String | Domain | The domain you want to add |
Example
await mcc.addDomain({
domain: "example.com",
}))
Boolean
Edits one or more domains on the server. Applies the attributes to all domains provided.
Kind: instance method of MailcowApiClient
Returns: Boolean
- True on success
Param | Type | Description |
---|---|---|
domains | Array | String | The domains you want to edit |
attributes | Object | Attributes to change for all domains provided domains |
Example
await mcc.editDomain(["example.com"], {
aliases: 399
});
//This will set the aliases of example.com to 399
Boolean
Removes a domain from the server
Kind: instance method of MailcowApiClient
Returns: Boolean
- True on success
Param | Type | Description |
---|---|---|
domain | String | Array | The domain/domains you want to delete |
Example
await mcc.deleteDomain("example.com")
Boolean
Generates a DKIM domain key for a domain
Kind: instance method of MailcowApiClient
Returns: Boolean
- True on success
Param | Type | Description |
---|---|---|
dkim | String | DKIM | A DKIM object or string |
Example
await mcc.addDKIM({
domain: "example.com",
})
//This will generate a DKIM key for example.com on the mailcow server
Object
Gets the DKIM key for a domain on the mailcow server
Kind: instance method of MailcowApiClient
Returns: Object
- The DKIM public key and other parameters
Param | Type | Description |
---|---|---|
domain | String | the domain name you want to get the key for |
Example
await mcc.getDKIM('example.com')
//This will get the DKIM key for the domain example.com from the mailcow server
Boolean
Deletes the DKIM key for a domain on the mailcow server
Kind: instance method of MailcowApiClient
Returns: Boolean
- true on success
Param | Type | Description |
---|---|---|
domain | Array | the domain name/names you want to delete the key for |
Example
await mcc.deleteDKIM('example.com')
//This will delete the DKIM key for the domain example.com from the mailcow server
Object
Generates a DKIM domain key for a domain and returns it
Kind: instance method of MailcowApiClient
Returns: Object
- DKIM key on success
Param | Type | Description |
---|---|---|
dkim | String | DKIM | A DKIM object or string |
Example
await mcc.addAndGetDKIM({
domain: "example.com",
})
//This will generate a DKIM key for example.com on the mailcow server and return it
Object
Adds a domain admin to the mailcow server
Kind: instance method of MailcowApiClient
Returns: Object
- containing password username and domains on successfull creation
Param | Type | Description |
---|---|---|
domainAdmin | DomainAdmin | a domain admin object that has to contain at least the domains the admin should be able to control |
Example
await mcc.addDomainAdmin({
domains: ['example.com', 'example.org']
})
//This will add an admin for the domains example.com and example.org and return their credentials
Object
Adds a mailbox for a domain to the mailcow server
Kind: instance method of MailcowApiClient
Returns: Object
- the created mailbox
Param | Type | Description |
---|---|---|
mailbox | Mailbox | a Mailbox object that has to contain at least the domain for which the mailbox shall be created |
Example
await mcc.addMailbox({
domain: 'example.com',
name: 'Example'
})
//This will add a mailbox for the domain example.com and return it
Boolean
Deletes a mailbox
Kind: instance method of MailcowApiClient
Returns: Boolean
- true on success
Param | Type | Description |
---|---|---|
mailboxes | String | Array | complete name of the mailbox/mailboxes |
Example
await mcc.deleteMailbox("mail@example.com")
//This will delete the mailbox mail@example.com
Boolean
Adds an alias for a mailbox
Kind: instance method of MailcowApiClient
Returns: Boolean
- true on success
Param | Type | Description |
---|---|---|
address | String | alias address, for catchall use "@domain.tld" |
goto | String | destination address, comma separated |
Example
await mcc.addAlias("@test.tld","mail@example.com")
//This will catch all mail for the domain test.tld and put it in the mailbox mail@example.com
Object
For all options check out https://demo.mailcow.email/api/
Kind: global typedef
Properties
Name | Type | Default | Description |
---|---|---|---|
domain | String | Name of the domain to add | |
[active] | Number | 1 | Whether the domain should be active or not |
[aliases] | Number | 400 | Number of aliases allowed |
[defquota] | Number | 3072 | |
[mailboxes] | Number | 10 | |
[maxquota] | Number | 10240 | |
[quota] | Number | 10240 |
Example
{
active: 1,
domain: "example.com",
aliases: 400, // responding "object is not numeric" if missing is this a BUG? should be "aliases missing" if cant be omited anyway
backupmx: 0,
defquota: 3072,
description: "Hello!",
lang: "en",
mailboxes: 10,
maxquota: 10240,
quota: 10240,
relay_all_recipients: 0,
rl_frame: "s",
rl_value: 10
}
Object
Object representing a DKIM Key
Kind: global typedef
Properties
Name | Type | Default | Description |
---|---|---|---|
domain | String | The domain which a key should be generated for | |
[dkim_selector] | String | 'dkim' | The dkim selector |
[key_size] | 2048 | 1024 | 2048 | The size of the key |
Example
{
"domain": "example.com",
"dkim_selector": "dkim",
"key_size": 2048
}
Object
Object representing a domain admin
Kind: global typedef
Properties
Name | Type | Default | Description |
---|---|---|---|
domains | Array | String | The domains/domain this admin should be able to access | |
[username] | String | RANDOM | |
[password] | String | RANDOM | |
[active] | 0 | 1 | 1 |
Example
{
"active": 1,
"domains": "example.com",
"password": "supersecurepw",
"username": "testadmin"
}
Object
Object representing a mailbox
Kind: global typedef
Properties
Name | Type | Default | Description |
---|---|---|---|
domain | String | domain for wich the mailbox shall be created | |
[local_part] | String | "mail" | the local part of the mail address before the @ |
[name] | String | "John Doe" | full name of the user |
[password] | String | RANDOM | password for the user. if omitted one will be generated |
[quota] | Number | 3072 | maximum size of the mailbox |
[active] | 0 | 1 | 1 | whether the mailbox is active or not |
Example
{
"domain": "example.com",
"local_part": "john.doe",
"name": "John Doe",
"password": "paulIstToll",
"quota": 3072,
"active": 1
}
FAQs
A wrapper for the mailcow wep API with the most relevant functions.
We found that mailcow-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.