diff --git a/README.md b/README.md index 7f30580..7b2d4f5 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ The authenticated-user ratelimit map is configured in `/etc/rspamd/custom_rateli Postfix updates a mailbox's `last_login` timestamp when an authenticated SMTP session reaches the `MAIL FROM` command. Install the policy script at `/var/www/mail/tools/postfix_last_login_policy.php` and reload Postfix after updating `/etc/postfix/main.cf` and `/etc/postfix/master.cf`. An SMTP session that authenticates but disconnects before `MAIL FROM` cannot be recorded by this policy hook. +Mailbox owners can add identity addresses on their mailbox domain from account settings; administrators can associate addresses on domains they manage from the mailbox editor. Identity addresses deliver only to their owner, are hidden from the regular alias list, and are authorized as sender addresses only for that mailbox's SMTP login. + Create a password used for your TURN server and replace all `YOUR_SECRET` in `/etc/prosody/prosody.cfg.lua` with it. Install [acme.sh](https://github.com/acmesh-official/acme.sh) or [certbot](https://certbot.eff.org/) to obtain a free letsencrypt SSL certificate, then update the path to this new certificate in the following files: diff --git a/common_config.php b/common_config.php index c3ffa0e..e80b7eb 100644 --- a/common_config.php +++ b/common_config.php @@ -9,7 +9,7 @@ const DBHOST = 'localhost'; // Database host const DBUSER = 'postfix'; // Database user const DBPASS = 'YOUR_PASSWORD'; // Database password const DBNAME = 'postfix'; // Database -const DBVERSION = 11; // Database schema version +const DBVERSION = 12; // Database schema version const INACTIVITY_PERIOD_MONTHS = [1, 6, 12, 24]; // Allowed inactivity periods in months - don't forget to update get_inactivity_period_options on changes here and if an option is removed, you should also update accounts in the database mailbox table const DEFAULT_INACTIVITY_PERIOD = 12; // Default inactivity period in months const ALLOW_ACCOUNT_NEVER_DELETE = false; // Whether to allow users to set their inactivity period to "never delete" @@ -515,6 +515,46 @@ function check_email_valid( string $email, string &$msg = '' ): bool return true; } +function create_mailbox_identity( PDO $db, string $identityAddress, string $mailboxUsername, string &$msg = '', bool $allowOtherDomains = false ): bool +{ + $identityAddress = mb_strtolower( trim( $identityAddress ) ); + $stmt = $db->prepare( 'SELECT username, domain FROM mailbox WHERE username = ? AND active = 1;' ); + $stmt->execute( [ $mailboxUsername ] ); + $mailbox = $stmt->fetch( PDO::FETCH_ASSOC ); + if ( ! $mailbox ) { + $msg .= ''; + return false; + } + $mailboxUsername = $mailbox[ 'username' ]; + $mailboxDomain = $mailbox[ 'domain' ]; + if ( ! check_email_valid( $identityAddress, $msg ) ) { + return false; + } + $parser = new EmailParser( new EmailLexer() ); + $parser->parse( $identityAddress ); + $identityDomain = $parser->getDomainPart(); + if ( ! $allowOtherDomains && mb_strtolower( $identityDomain ) !== mb_strtolower( $mailboxDomain ) ) { + $msg .= ''; + return false; + } + $stmt = $db->prepare( 'SELECT domain FROM domain WHERE domain = ? AND active = 1;' ); + $stmt->execute( [ $identityDomain ] ); + $identityDomain = $stmt->fetchColumn(); + if ( ! is_string( $identityDomain ) ) { + $msg .= ''; + return false; + } + $stmt = $db->prepare( 'SELECT username FROM mailbox WHERE username = ? UNION SELECT address FROM alias WHERE address = ?;' ); + $stmt->execute( [ $identityAddress, $identityAddress ] ); + if ( $stmt->fetch() ) { + $msg .= ''; + return false; + } + $stmt = $db->prepare( 'INSERT INTO alias (address, goto, domain, created, modified, active, enforce_tls_in, identity) VALUES (?, ?, ?, NOW(), NOW(), 1, 1, ?);' ); + $stmt->execute( [ $identityAddress, $mailboxUsername, $identityDomain, $mailboxUsername ] ); + return true; +} + function parse_sender_address_list( string $value ): ?array { $validator = new EmailValidator(); diff --git a/etc/postfix/sql/mysql_virtual_auth_maps.cf b/etc/postfix/sql/mysql_virtual_auth_maps.cf index 6da648b..72ab1f1 100644 --- a/etc/postfix/sql/mysql_virtual_auth_maps.cf +++ b/etc/postfix/sql/mysql_virtual_auth_maps.cf @@ -2,4 +2,4 @@ user = postfix_readonly password = YOUR_PASSWORD hosts = localhost dbname = postfix -query = SELECT username FROM mailbox WHERE username=CONCAT('%u', '@', COALESCE((SELECT target_domain FROM alias_domain WHERE alias_domain = '%d' AND active='1'), '%d')) AND active = '1' +query = SELECT username FROM mailbox WHERE username=CONCAT('%u', '@', COALESCE((SELECT target_domain FROM alias_domain WHERE alias_domain = '%d' AND active='1'), '%d')) AND active = '1' UNION SELECT a.identity AS username FROM alias AS a INNER JOIN mailbox AS m ON m.username = a.identity WHERE a.address = CONCAT('%u', '@', COALESCE((SELECT target_domain FROM alias_domain WHERE alias_domain = '%d' AND active='1'), '%d')) AND a.active = '1' AND a.identity IS NOT NULL AND m.active = '1' diff --git a/setup.php b/setup.php index 0ab3eba..a594a7a 100644 --- a/setup.php +++ b/setup.php @@ -26,7 +26,7 @@ try{ $createTableStatements = [ 'admin' => "CREATE TABLE IF NOT EXISTS `admin` (`username` varchar(255) NOT NULL, `password` varchar(255) NOT NULL, `superadmin` tinyint(1) NOT NULL DEFAULT 0, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, `password_hash_type` varchar(20) NOT NULL DEFAULT '{MD5-CRYPT}', `totp_secret` varchar(64) DEFAULT NULL, PRIMARY KEY (`username`), KEY `active` (`active`)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;", 'domain' => "CREATE TABLE IF NOT EXISTS `domain` (`domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, `dkim_key` text NOT NULL DEFAULT '', `dkim_selector` varchar(20) NOT NULL DEFAULT '', PRIMARY KEY (`domain`), KEY `active` (`active`)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;", - 'alias' => "CREATE TABLE IF NOT EXISTS `alias` (`address` varchar(255) NOT NULL, `goto` text NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, `enforce_tls_in` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`address`), KEY `domain` (`domain`), KEY `active` (`active`), CONSTRAINT `alias_ibfk_1` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;", + 'alias' => "CREATE TABLE IF NOT EXISTS `alias` (`address` varchar(255) NOT NULL, `goto` text NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, `enforce_tls_in` tinyint(1) NOT NULL DEFAULT 1, `identity` varchar(255) DEFAULT NULL, PRIMARY KEY (`address`), KEY `domain` (`domain`), KEY `active` (`active`), KEY `identity` (`identity`), CONSTRAINT `alias_ibfk_1` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON UPDATE CASCADE, CONSTRAINT `alias_identity_ibfk_1` FOREIGN KEY (`identity`) REFERENCES `mailbox` (`username`) ON DELETE CASCADE ON UPDATE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;", 'alias_domain' => "CREATE TABLE IF NOT EXISTS `alias_domain` (`alias_domain` varchar(255) NOT NULL DEFAULT '', `target_domain` varchar(255) NOT NULL DEFAULT '', `created` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `modified` datetime NOT NULL DEFAULT '2000-01-01 00:00:00', `active` tinyint(1) NOT NULL DEFAULT 1, PRIMARY KEY (`alias_domain`), KEY `active` (`active`), KEY `target_domain` (`target_domain`)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;", 'captcha' => "CREATE TABLE IF NOT EXISTS `captcha` (`id` bigint(20) NOT NULL AUTO_INCREMENT, `time` int(11) NOT NULL, `code` char(5) NOT NULL, PRIMARY KEY (`id`)) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;", 'dmarc_report' => "CREATE TABLE IF NOT EXISTS `dmarc_report` (`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `report_id` varchar(255) NOT NULL, `email` varchar(255) NOT NULL, `org_name` varchar(255) NOT NULL, `begin` datetime NOT NULL, `end` datetime NOT NULL, `domain` varchar(255) NOT NULL, `adkim` char(1) NOT NULL, `aspf` char(1) NOT NULL, `policy` varchar(10) NOT NULL, `subdomain_policy` varchar(10) NOT NULL, `pct` tinyint(3) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `report_id_org_name` (`report_id`,`org_name`), KEY `begin_end` (`begin`,`end`), KEY `domain` (`domain`), CONSTRAINT `dmarc_report_ibfk_1` FOREIGN KEY (`domain`) REFERENCES `domain` (`domain`) ON DELETE CASCADE) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;", @@ -138,6 +138,20 @@ try{ } } } + if ( $version < 12 ) { + $stmt = $db->query( "SHOW COLUMNS FROM `alias` LIKE 'identity';" ); + if ( ! $stmt->fetch() ) { + $db->exec( 'ALTER TABLE `alias` ADD COLUMN `identity` varchar(255) DEFAULT NULL;' ); + } + $stmt = $db->query( "SHOW INDEX FROM `alias` WHERE `Key_name` = 'identity';" ); + if ( ! $stmt->fetch() ) { + $db->exec( 'ALTER TABLE `alias` ADD INDEX `identity` (`identity`);' ); + } + $stmt = $db->query( "SELECT CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'alias' AND COLUMN_NAME = 'identity' AND REFERENCED_TABLE_NAME = 'mailbox';" ); + if ( ! $stmt->fetch() ) { + $db->exec( 'ALTER TABLE `alias` ADD CONSTRAINT `alias_identity_ibfk_1` FOREIGN KEY (`identity`) REFERENCES `mailbox` (`username`) ON DELETE CASCADE ON UPDATE CASCADE;' ); + } + } $db->beginTransaction(); $stmt=$db->prepare("UPDATE `settings` SET `value`=? WHERE `setting`='version';"); $stmt->execute([DBVERSION]); diff --git a/www/admin.php b/www/admin.php index 837f1ae..7475489 100644 --- a/www/admin.php +++ b/www/admin.php @@ -146,6 +146,23 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $msg .= '
'; $msg .= ''; $msg .= '
'; + } elseif ( $_POST[ 'action' ] === 'add_mailbox_identity' && is_string( $_POST[ 'user' ] ?? null ) && $_POST[ 'user' ] !== '' && is_string( $_POST[ 'identity_address' ] ?? null ) && $_POST[ 'identity_address' ] !== '' ) { + $ok = check_domain_access( $_POST[ 'user' ], $msg ); + if ( $ok ) { + $ok = check_email_valid( $_POST[ 'identity_address' ], $msg ); + } + if ( $ok ) { + $ok = check_domain_access( $_POST[ 'identity_address' ], $msg ); + } + if ( $ok && create_mailbox_identity( $db, $_POST[ 'identity_address' ], $_POST[ 'user' ], $msg, true ) ) { + $msg .= '
'.htmlspecialchars(_('Successfully added identity address.')).'
'; + } + } elseif ( $_POST[ 'action' ] === 'delete_mailbox_identity' && is_string( $_POST[ 'user' ] ?? null ) && $_POST[ 'user' ] !== '' && is_string( $_POST[ 'identity_address' ] ?? null ) && $_POST[ 'identity_address' ] !== '' ) { + if ( check_domain_access( $_POST[ 'user' ], $msg ) ) { + $stmt = $db->prepare( 'DELETE FROM alias WHERE address = ? AND identity = ?;' ); + $stmt->execute( [ $_POST[ 'identity_address' ], $_POST[ 'user' ] ] ); + $msg .= '
'.htmlspecialchars(_('Successfully removed identity address.')).'
'; + } } elseif ( $_POST[ 'action' ] === 'delete_admin2' && ! empty( $_POST[ 'admin' ] ) && $_SESSION[ 'email_admin_superadmin' ] ) { if ( $_SESSION[ 'email_admin_user' ] === $_POST[ 'admin' ] ) { $msg .= ''; @@ -164,7 +181,7 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $msg .= ''; } elseif ( $_POST[ 'action' ] === 'delete_alias2' && ! empty( $_POST[ 'alias' ] ) ) { if ( check_domain_access( $_POST[ 'alias' ], $msg ) ) { - $stmt = $db->prepare( 'DELETE FROM alias WHERE address = ?;' ); + $stmt = $db->prepare( 'DELETE FROM alias WHERE address = ? AND identity IS NULL;' ); $stmt->execute( [ $_POST[ 'alias' ] ] ); $msg .= ''; } @@ -172,6 +189,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { if ( check_domain_access( $_POST[ 'user' ], $msg ) ) { $stmt = $db->prepare( 'UPDATE mailbox SET active = -2 WHERE username = ?;' ); $stmt->execute( [ $_POST[ 'user' ] ] ); + $stmt = $db->prepare( 'UPDATE alias SET active = 0 WHERE address = ? OR identity = ?;' ); + $stmt->execute( [ $_POST[ 'user' ], $_POST[ 'user' ] ] ); $msg .= ''; } } elseif ( $_POST[ 'action' ] === 'save_edit_admin' && ! empty( $_POST[ 'admin' ] ) && ( $_SESSION[ 'email_admin_superadmin' ] || $_POST[ 'admin' ] === $_SESSION[ 'email_admin_user' ] ) ) { @@ -354,7 +373,7 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $alias_goto = validate_email_list( $targets, $msg ); $active = isset( $_POST[ 'active' ] ) ? 1 : 0; $enforce_tls_in = isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0; - $stmt = $db->prepare( 'UPDATE alias SET goto = ?, active = ?, enforce_tls_in = ?, modified = NOW() WHERE address = ?;' ); + $stmt = $db->prepare( 'UPDATE alias SET goto = ?, active = ?, enforce_tls_in = ?, modified = NOW() WHERE address = ? AND identity IS NULL;' ); $stmt->execute( [ $alias_goto, $active, $enforce_tls_in, $_POST[ 'alias' ] ] ); $msg .= ''; } @@ -393,6 +412,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $alias_goto = rtrim( $alias_goto, ',' ); $stmt = $db->prepare( 'UPDATE alias SET goto = ?, enforce_tls_in = ?, active = ? WHERE address = ?;' ); $stmt->execute( [ $alias_goto, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), $_POST[ 'user' ] ] ); + $stmt = $db->prepare( 'UPDATE alias SET active = ? WHERE identity = ?;' ); + $stmt->execute( [ ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), $_POST[ 'user' ] ] ); $stmt = $db->prepare( 'UPDATE mailbox SET enforce_tls_in = ?, enforce_tls_out = ?, active = ?, trusted = ?, quota = ?, inactivity_period = ?, spam_reject_score = ?, blocked_senders = ?, whitelisted_senders = ?, modified = NOW() WHERE username = ?;' ); $stmt->execute( [ ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), ( isset( $_POST[ 'active' ] ) ? 1 : 0 ), ( isset( $_POST[ 'trusted' ] ) ? 1 : 0 ), DEFAULT_QUOTA, $inactivity_period, $spam_reject_score, implode( "\n", $blocked_senders ), implode( "\n", $whitelisted_senders ), $_POST[ 'user' ] ] ); $msg .= '
'.htmlspecialchars(_('Successfully updated mailbox.')).'
'; @@ -559,7 +580,7 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { send_edit_alias_domain(); } elseif ( in_array( $_REQUEST[ 'action' ], [ 'edit_alias', 'save_edit_alias' ], true ) ) { send_edit_alias(); - } elseif ( in_array( $_REQUEST[ 'action' ], [ 'edit_mailbox', 'save_edit_mailbox', 'save_password_mailbox', 'disable_tfa_mailbox' ], true ) ) { + } elseif ( in_array( $_REQUEST[ 'action' ], [ 'edit_mailbox', 'save_edit_mailbox', 'save_password_mailbox', 'disable_tfa_mailbox', 'add_mailbox_identity', 'delete_mailbox_identity' ], true ) ) { send_edit_mailbox(); } elseif ( empty( $msg ) ) { ?>

prepare( 'SELECT COUNT(*) FROM alias AS a LEFT JOIN mailbox AS m ON (m.username=a.address AND m.active=1) WHERE a.domain IN (SELECT domain FROM domain_admins WHERE username = :username) AND isnull(m.username);' ); + $countStmt = $db->prepare( 'SELECT COUNT(*) FROM alias AS a LEFT JOIN mailbox AS m ON (m.username=a.address AND m.active=1) WHERE a.domain IN (SELECT domain FROM domain_admins WHERE username = :username) AND isnull(m.username) AND a.identity IS NULL;' ); $countStmt->bindValue( ':username', $_SESSION[ 'email_admin_user' ], PDO::PARAM_STR ); $countStmt->execute(); $total = (int) $countStmt->fetchColumn(); $totalPages = max( 1, (int) ceil( $total / ADMIN_LIST_PAGE_SIZE ) ); - $stmt = $db->prepare( 'SELECT a.address, a.goto, a.modified, a.active FROM alias AS a LEFT JOIN mailbox AS m ON (m.username=a.address AND m.active=1) WHERE a.domain IN (SELECT domain FROM domain_admins WHERE username = :username) AND isnull(m.username) ORDER BY a.address LIMIT :limit OFFSET :offset;' ); + $stmt = $db->prepare( 'SELECT a.address, a.goto, a.modified, a.active FROM alias AS a LEFT JOIN mailbox AS m ON (m.username=a.address AND m.active=1) WHERE a.domain IN (SELECT domain FROM domain_admins WHERE username = :username) AND isnull(m.username) AND a.identity IS NULL ORDER BY a.address LIMIT :limit OFFSET :offset;' ); $stmt->bindValue( ':username', $_SESSION[ 'email_admin_user' ], PDO::PARAM_STR ); $stmt->bindValue( ':limit', ADMIN_LIST_PAGE_SIZE, PDO::PARAM_INT ); $stmt->bindValue( ':offset', $offset, PDO::PARAM_INT ); @@ -1095,7 +1116,7 @@ function send_new_alias(): void function send_edit_alias(): void { $db = get_db_instance(); - $stmt = $db->prepare( 'SELECT a.address, a.goto, a.active, a.enforce_tls_in FROM alias AS a LEFT JOIN mailbox AS m ON (m.username=a.address AND m.active=1) WHERE a.address = :alias AND isnull(m.username);' ); + $stmt = $db->prepare( 'SELECT a.address, a.goto, a.active, a.enforce_tls_in FROM alias AS a LEFT JOIN mailbox AS m ON (m.username=a.address AND m.active=1) WHERE a.address = :alias AND isnull(m.username) AND a.identity IS NULL;' ); $stmt->bindValue( ':alias', $_POST[ 'alias' ], PDO::PARAM_STR ); $stmt->execute(); if ( $alias = $stmt->fetch( PDO::FETCH_ASSOC ) ) { @@ -1311,6 +1332,32 @@ function send_edit_mailbox(): void +

+

+ prepare( 'SELECT address FROM alias WHERE identity = ? ORDER BY address;' ); + $identityStmt->execute( [ $_REQUEST[ 'user' ] ] ); + while ( $identity = $identityStmt->fetch( PDO::FETCH_ASSOC ) ) { + ?> +
+ + + + + +
+ +
+ + +
+
+
+
+ +

diff --git a/www/manage_account.php b/www/manage_account.php index 44028a8..168d74d 100644 --- a/www/manage_account.php +++ b/www/manage_account.php @@ -120,6 +120,17 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $stmt->execute( [ $alias_goto, ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), $_SESSION[ 'email_user' ] ] ); $stmt = $db->prepare( 'UPDATE mailbox SET enforce_tls_in = ?, enforce_tls_out = ? WHERE username = ? AND active = 1;' ); $stmt->execute( [ ( isset( $_POST[ 'enforce_tls_in' ] ) ? 1 : 0 ), ( isset( $_POST[ 'enforce_tls_out' ] ) ? 1 : 0 ), $_SESSION[ 'email_user' ] ] ); + } elseif ( ! empty( $_SESSION[ 'email_user' ] ) && $_POST[ 'action' ] === 'add_identity' ) { + $identityAddress = $_POST[ 'identity_address' ] ?? ''; + if ( ! is_string( $identityAddress ) ) { + $msg .= ''; + } elseif ( create_mailbox_identity( $db, $identityAddress, $_SESSION[ 'email_user' ], $msg ) ) { + $msg .= '
'.htmlspecialchars(_('Successfully added identity address.')).'
'; + } + } elseif ( ! empty( $_SESSION[ 'email_user' ] ) && $_POST[ 'action' ] === 'delete_identity' && is_string( $_POST[ 'identity_address' ] ?? null ) && $_POST[ 'identity_address' ] !== '' ) { + $stmt = $db->prepare( 'DELETE FROM alias WHERE address = ? AND identity = ?;' ); + $stmt->execute( [ $_POST[ 'identity_address' ], $_SESSION[ 'email_user' ] ] ); + $msg .= '
'.htmlspecialchars(_('Successfully removed identity address.')).'
'; } elseif ( ! empty( $_SESSION[ 'email_user' ] ) && $_POST[ 'action' ] === 'update_inactivity_period' ) { $inactivity_period = filter_var( $_POST[ 'inactivity_period' ] ?? null, FILTER_VALIDATE_INT ); $valid_inactivity_period = $inactivity_period !== false && ( @@ -178,8 +189,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { $msg .= ''; $msg .= '
'; } elseif ( ! empty( $_SESSION[ 'email_user' ] ) && $_POST[ 'action' ] === 'delete_account2' ) { - $stmt = $db->prepare( 'DELETE FROM alias WHERE address = ?;' ); - $stmt->execute( [ $_SESSION[ 'email_user' ] ] ); + $stmt = $db->prepare( 'DELETE FROM alias WHERE address = ? OR identity = ?;' ); + $stmt->execute( [ $_SESSION[ 'email_user' ], $_SESSION[ 'email_user' ] ] ); $stmt = $db->prepare( 'UPDATE mailbox SET active = -2 WHERE username = ? AND active = 1;' ); $stmt->execute( [ $_SESSION[ 'email_user' ] ] ); $_SESSION = []; @@ -189,6 +200,8 @@ if ( $_SERVER[ 'REQUEST_METHOD' ] === 'POST' ) { } elseif ( ! empty( $_SESSION[ 'email_user' ] ) && $_POST[ 'action' ] === 'disable_account2' ) { $stmt = $db->prepare( 'UPDATE alias SET active = 0 WHERE address = ?;' ); $stmt->execute( [ $_SESSION[ 'email_user' ] ] ); + $stmt = $db->prepare( 'UPDATE alias SET active = 0 WHERE identity = ?;' ); + $stmt->execute( [ $_SESSION[ 'email_user' ] ] ); $stmt = $db->prepare( 'UPDATE mailbox SET active = -1 WHERE username = ? AND active = 1;' ); $stmt->execute( [ $_SESSION[ 'email_user' ] ] ); $_SESSION = []; @@ -437,6 +450,31 @@ if ( empty( $_SESSION[ 'email_user' ] ) ) { ?> +

+

+ prepare( 'SELECT address FROM alias WHERE identity = ? ORDER BY address;' ); + $identityStmt->execute( [ $_SESSION[ 'email_user' ] ] ); + while ( $identity = $identityStmt->fetch( PDO::FETCH_ASSOC ) ) { + ?> +
+ + + + +
+ +
+ +
+
+
+
+ +
+