Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3e33add
IONOS(ionos-mail): feat(provider): implement external mail account pr…
printminion-co Dec 19, 2025
d6b8b7b
IONOS(ionos-mail): refactor(dtos): move DTOs to shared Common namespace
printminion-co Dec 19, 2025
96b5b9d
IONOS(ionos-mail): feat(provider): add provider availability check an…
printminion-co Dec 23, 2025
00736cc
IONOS(ionos-mail): refactor(service): allow optional user ID paramete…
printminion-co Dec 29, 2025
0c793ba
IONOS(ionos-mail): feat(provider): implement IONOS Nextcloud Workspac…
printminion-co Dec 23, 2025
04b1894
IONOS(ionos-mail): feat(provider): register IonosProvider during appl…
printminion-co Dec 23, 2025
47e66e0
IONOS(ionos-mail): feat(frontend): add generic ExternalProviderTab co…
printminion-co Dec 22, 2025
52e0fe7
IONOS(ionos-mail): refactor(routes): remove legacy IONOS routes
printminion-co Dec 22, 2025
ed5a74f
IONOS(ionos-mail): refactor(services): move IONOS services to provide…
printminion-co Dec 22, 2025
c17bd83
IONOS(ionos-mail): feat(frontend): add retry logic for IMAP connectio…
printminion-co Dec 24, 2025
4896e4c
IONOS(ionos-mail): feat(commands): add occ commands for mail account …
printminion-co Dec 29, 2025
b7bd20f
IONOS(ionos-mail): chore(commands): register provider commands in inf…
printminion-co Dec 29, 2025
98235ac
IONOS(ionos-mail): feat(provider): add endpoint to generate app passw…
printminion-co Dec 30, 2025
c344c2b
IONOS(ionos-mail): feat(provider): implement IONOS Nextcloud Workspac…
printminion-co Dec 30, 2025
e3cd961
IONOS(ionos-mail): feat(commands): add occ command for mail account p…
printminion-co Dec 30, 2025
6555f55
IONOS(ionos-mail): chore(commands): register ProviderGenerateAppPassw…
printminion-co Dec 30, 2025
5c43845
IONOS(ionos-mail): docs(commands): add comprehensive provider command…
printminion-co Dec 29, 2025
d024166
IONOS(ionos-mail): refactor(provider): change AccountProviderService …
printminion-co Dec 30, 2025
361b8fe
IONOS(ionos-mail): refactor(controller): enhance account creation res…
printminion-co Dec 30, 2025
32f8d27
IONOS(ionos-mail): feat(frontend): add app password reset UI for prov…
printminion-co Dec 30, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ Learn more about the Nextcloud Ethical AI Rating [in our blog](https://nextcloud
<command>OCA\Mail\Command\ExportAccount</command>
<command>OCA\Mail\Command\ExportAccountThreads</command>
<command>OCA\Mail\Command\PredictImportance</command>
<command>OCA\Mail\Command\ProviderCreateAccount</command>
<command>OCA\Mail\Command\ProviderGenerateAppPassword</command>
<command>OCA\Mail\Command\ProviderList</command>
<command>OCA\Mail\Command\ProviderStatus</command>
<command>OCA\Mail\Command\SyncAccount</command>
<command>OCA\Mail\Command\Thread</command>
<command>OCA\Mail\Command\TrainAccount</command>
Expand Down
14 changes: 12 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,18 @@
'verb' => 'POST'
],
[
'name' => 'ionosAccounts#create',
'url' => '/api/ionos/accounts',
'name' => 'externalAccounts#getProviders',
'url' => '/api/providers',
'verb' => 'GET'
],
[
'name' => 'externalAccounts#create',
'url' => '/api/providers/{providerId}/accounts',
'verb' => 'POST'
],
[
'name' => 'externalAccounts#generatePassword',
'url' => '/api/providers/{providerId}/password',
'verb' => 'POST'
],
[
Expand Down
246 changes: 246 additions & 0 deletions doc/provider-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,246 @@
# Provider OCC Commands

This document describes the new OCC commands for managing external mail account providers (e.g., IONOS Mail).

## Available Commands

### 1. `mail:provider:list`

List all registered mail account providers and their capabilities.

**Usage:**
```bash
php occ mail:provider:list
```

**Example Output:**
```
Registered Mail Account Providers:

+--------+------------+---------+-------------------+--------------+----------------+--------------+
| ID | Name | Enabled | Multiple Accounts | App Passwords| Password Reset | Email Domain |
+--------+------------+---------+-------------------+--------------+----------------+--------------+
| ionos | IONOS Mail | Yes | No | Yes | Yes | example.com |
+--------+------------+---------+-------------------+--------------+----------------+--------------+

IONOS Mail (ionos):
Configuration Parameters:
- ionos_mailconfig_api_base_url (string, required): Base URL for the IONOS Mail Configuration API
- ionos_mailconfig_api_auth_user (string, required): Basic auth username for IONOS API
- ionos_mailconfig_api_auth_pass (string, required): Basic auth password for IONOS API
- ionos_mailconfig_api_allow_insecure (boolean): Allow insecure connections (for development)
- ncw.ext_ref (string, required): External reference ID (system config)
- ncw.customerDomain (string, required): Customer domain for email addresses (system config)
Account Creation Parameters:
- accountName (string, required): Name
- emailUser (string, required): User
```

---

### 2. `mail:provider:status`

Check the status and availability of a mail account provider.

**Usage:**
```bash
php occ mail:provider:status <provider-id> [<user-id>] [--verbose|-v]
```

**Arguments:**
- `provider-id` (required): Provider ID (e.g., "ionos")
- `user-id` (optional): User ID to check provider availability for specific user

**Options:**
- `-v, --verbose`: Show detailed information including capabilities

**Examples:**

Check provider status:
```bash
php occ mail:provider:status ionos
```

Check if provider is available for a specific user:
```bash
php occ mail:provider:status ionos alice
```

With verbose output:
```bash
php occ mail:provider:status ionos alice -v
```

**Example Output:**
```
Provider: IONOS Mail (ionos)

Enabled: Yes

User: alice
Available for User: Yes
```

---

### 3. `mail:provider:create-account`

Create a mail account via an external provider.

**Usage:**
```bash
php occ mail:provider:create-account <provider-id> <user-id> -p <key>=<value> ...
```

**Arguments:**
- `provider-id` (required): Provider ID (e.g., "ionos")
- `user-id` (required): User ID to create the account for

**Options:**
- `-p, --param`: Parameters in key=value format (can be used multiple times)

**Example:**
```bash
php occ mail:provider:create-account ionos alice \
-p emailUser=alice \
-p accountName="Alice Smith"
```

**Example Output:**
```
Creating account for user "alice" via provider "ionos"...

Account created successfully!

Account ID: 42
Email: [email protected]
Name: Alice Smith
IMAP Host: imap.example.com:993
SMTP Host: smtp.example.com:587
```

---

### 4. `mail:provider:generate-app-password`

Generate a new app password for a provider-managed mail account.

**Usage:**
```bash
php occ mail:provider:generate-app-password <provider-id> <user-id>
```

**Arguments:**
- `provider-id` (required): Provider ID (e.g., "ionos")
- `user-id` (required): User ID to generate app password for

**Example:**
```bash
php occ mail:provider:generate-app-password ionos alice
```

**Example Output:**
```
Generating app password for user "alice" (email: [email protected])...

App password generated successfully!

New App Password: AbCd1234EfGh5678IjKl

IMPORTANT: This password will only be shown once. Make sure to save it securely.
The mail account in Nextcloud has been automatically updated with the new password.
```

---

## Common Workflows

### Initial Setup

1. **List available providers:**
```bash
php occ mail:provider:list
```

2. **Check provider configuration:**
```bash
php occ mail:provider:status ionos -v
```

### Account Management

1. **Create a new account:**
```bash
php occ mail:provider:create-account ionos alice \
-p emailUser=alice \
-p accountName="Alice Smith"
```

2. **Reset password (generate app password):**
```bash
php occ mail:provider:generate-app-password ionos alice
```

### Troubleshooting

1. **Check if provider is available for user:**
```bash
php occ mail:provider:status ionos alice
```

2. **Verify provider configuration:**
```bash
php occ mail:provider:list
```

---

## Error Handling

The commands provide clear error messages:

- **Provider not found:** Lists available providers
- **User does not exist:** Validates user existence
- **Provider not enabled:** Suggests checking configuration
- **Provider not available for user:** Explains why (e.g., account already exists)
- **Missing required parameters:** Shows what parameters are needed with descriptions

---

## Testing

All commands include comprehensive unit tests:
- `tests/Unit/Command/ProviderListTest.php`
- `tests/Unit/Command/ProviderStatusTest.php`
- `tests/Unit/Command/ProviderCreateAccountTest.php`
- `tests/Unit/Command/ProviderGenerateAppPasswordTest.php`

Run tests:
```bash
vendor/bin/phpunit -c tests/phpunit.unit.xml tests/Unit/Command/Provider*
```

---

## Implementation Details

### Architecture

All provider commands follow the same pattern:
1. Validate inputs (provider ID, user ID, parameters)
2. Check provider status and availability
3. Execute the operation via `ProviderRegistryService`
4. Provide detailed feedback to the user

### Dependencies

Commands use:
- `ProviderRegistryService`: Access to registered providers
- `IUserManager`: User validation
- Symfony Console components for CLI interaction

### Code Location

- Commands: `lib/Command/Provider*.php`
- Tests: `tests/Unit/Command/Provider*Test.php`
- Registration: `appinfo/info.xml`
16 changes: 16 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
use OCA\Mail\Listener\TaskProcessingListener;
use OCA\Mail\Listener\UserDeletedListener;
use OCA\Mail\Notification\Notifier;
use OCA\Mail\Provider\MailAccountProvider\Implementations\IonosProvider;
use OCA\Mail\Provider\MailAccountProvider\ProviderRegistryService;
use OCA\Mail\Provider\MailProvider;
use OCA\Mail\Search\FilteringProvider;
use OCA\Mail\Service\Attachment\AttachmentService;
Expand Down Expand Up @@ -172,5 +174,19 @@ public function register(IRegistrationContext $context): void {

#[\Override]
public function boot(IBootContext $context): void {
$container = $context->getServerContainer();

// Register mail account providers
try {
$providerRegistry = $container->get(ProviderRegistryService::class);
$ionosProvider = $container->get(IonosProvider::class);
$providerRegistry->registerProvider($ionosProvider);
} catch (\Exception $e) {
// Log but don't fail - provider registration is optional
$logger = $container->get(\Psr\Log\LoggerInterface::class);
$logger->error('Failed to register mail account providers', [
'exception' => $e,
]);
}
}
}
Loading
Loading