fix: enhance SMTP API password handling with app password support

This commit is contained in:
Mohammad R. Tayyebi 2026-01-02 12:17:29 +03:30
parent cb0056acc5
commit 299a81502a
2 changed files with 12 additions and 2 deletions

View file

@ -6183,8 +6183,18 @@ paths:
description: SMTP username (mailbox login; required)
type: string
password:
description: SMTP password (mailbox login; required)
description: >
SMTP password (mailbox password or mailbox app password; required).
App passwords are recommended for API usage.
type: string
example: "app-password-or-mailbox-password"
app_password:
description: >
Alias for `password`.
SMTP password (mailbox password or mailbox app password; required).
App passwords are recommended for API usage.
type: string
example: "app-password-or-mailbox-password"
required:
- from
- to

View file

@ -3413,7 +3413,7 @@ function smtp_api($action, $data) {
// SMTP settings - mailbox-level auth; default to 587 (STARTTLS)
$smtp_host = isset($data['smtp_host']) ? $data['smtp_host'] : 'postfix-mailcow';
$smtp_user = isset($data['smtp_user']) ? $data['smtp_user'] : '';
$smtp_pass = isset($data['password']) ? $data['password'] : '';
$smtp_pass = $data['app_password'] ?? $data['password'] ?? '';
$smtp_port = isset($data['smtp_port']) ? intval($data['smtp_port']) : 587;
// Validate from address