Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set recovery_email while Creating a mailbox via API #6072

Open
mostafa0017 opened this issue Sep 11, 2024 · 2 comments
Open

Set recovery_email while Creating a mailbox via API #6072

mostafa0017 opened this issue Sep 11, 2024 · 2 comments
Assignees

Comments

@mostafa0017
Copy link

Summary

Currently, If I sent a get request to get a mailbox I receive:

[
    {
        "username": "test@example.com",
        "active": 1,
        "active_int": 1,
        "domain": "example.com",
        "name": "Joe Doe",
        "local_part": "test",
        "quota": 0,
        "messages": 31,
        "attributes": {
            "force_pw_update": "0",
            "tls_enforce_in": "1",
            "tls_enforce_out": "1",
            "sogo_access": "0",
            "imap_access": "1",
            "pop3_access": "1",
            "smtp_access": "1",
            "sieve_access": "1",
            "relayhost": "0",
            "passwd_update": "2024-09-03 15:31:39",
            "mailbox_format": "maildir:",
            "quarantine_notification": "hourly",
            "quarantine_category": "reject",
            "recovery_email": "recovery@fortest.com"
        },
        "custom_attributes": [],
        "quota_used": 121623,
        "percent_in_use": "- ",
        "created": "2024-09-01 12:56:24",
        "modified": "2024-09-05 14:19:00",
        "percent_class": "info",
        "last_imap_login": 1725969402,
        "last_smtp_login": 1725959252,
        "last_pop3_login": 0,
        "max_new_quota": 9269411840,
        "spam_aliases": 0,
        "pushover_active": 0,
        "rl": false,
        "rl_scope": "domain",
        "is_relayed": 0,
        "tags": [
            "Staff"
        ]
    }
]

So I wanted to use recovery_email in a POST request to create a mailbox, but sadly this value is ignored if I tried and a mailbox gets created without it.

Motivation

It would benefit all the API users by adding another value to be set while creating a mailbox.

Additional context

No response

@DerLinkman
Copy link
Member

Is there no endpoint in the API @FreddleSpl0it?

@samirss56
Copy link

samirss56 commented Oct 4, 2024

So I wanted to use recovery_email in a POST request to create a mailbox, but sadly this >value is ignored if I tried and a mailbox gets created without it.

edit file /opt/mailcowdockerized/data/web/inc/functions.mailbox.inc.php

goto line 1079: add recovery_email as follows:

1078 $recovery_email = (isset($_data['recovery_email'])) ? strval($_data['recovery_email']) : strval($MAILBOX_DEFAULT_ATTRIBUTES['recovery_email']);

1079 $mailbox_attrs = json_encode(
1080

goto line 1094: add recovery_email as follows:

1094 'attribute_hash' => $attribute_hash,
1095 'recovery_email' => $recovery_email

docker compose down ; docker compose up -d

curl example to create mailbox with recovery email:

curl -v -X 'POST' \ 'https://your-maildoain.tld/api/v1/add/mailbox' \ -H 'X-API-Key: your api-key' \ -H 'Content-Type: application/json' \ -d '{ "active": "1", "domain": "yourdomain.tld", "local_part": "info3", "name": "Full name", "password": "123123", "password2": "123123", "quota": "3072", "force_pw_update": "0", "tls_enforce_in": "1", "tls_enforce_out": "1", "recovery_email": "recovery_email@hotmail.com" }'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants