Refactor email account configuration for multi-account support

Refactored `EmailAccountDto` to represent a single account with
immutable properties and added an `Id` field. Introduced
`EmailAccountsOptions` to manage multiple accounts and bound it
to the `EmailAccounts` configuration section.

Updated `DependencyInjection` to register `EmailAccountsOptions`
and removed the old single-account binding. Refactored
`LimilabsEmailService` to use `EmailAccountsOptions` and select
the appropriate account dynamically.

Replaced the `EmailAccount` section in `appsettings.Secrets.json`
with a new `EmailAccounts` section supporting multiple accounts.
Added a package reference for `Microsoft.Extensions.Options.
ConfigurationExtensions` to support the options pattern.
This commit is contained in:
2026-08-05 10:46:43 +02:00
parent e6df623538
commit e53fabcda2
7 changed files with 67 additions and 34 deletions

View File

@@ -67,10 +67,6 @@ try
// Register Infrastructure layer (RabbitMQ, Repositories, etc.)
builder.Services.AddInfrastructure(builder.Configuration);
// Register EmailAccount configuration (IOptions<EmailAccountDto>)
builder.Services.Configure<EmailAccountDto>(
builder.Configuration.GetSection("EmailAccount"));
builder.Services.AddControllers();
builder.Services.AddEndpointsApiExplorer();

View File

@@ -15,13 +15,18 @@
"DlqExchangeName": "emailprofiler.emails.dlq",
"DlqRoutingKey": "email.outbox.dlq"
},
"EmailAccount": {
"Username": "test-flow@digitaldata.works",
"Password": "ddemail108",
"PasswordEncrypted": false,
"SmtpServer": "kundencenter.triplew.de",
"SmtpPort": 465,
"SmtpUseSsl": true,
"UseOAuth2": false
"EmailAccounts": {
"Accounts": [
{
"Name": "1",
"Username": "test-flow@digitaldata.works",
"Password": "ddemail108",
"PasswordEncrypted": false,
"SmtpServer": "kundencenter.triplew.de",
"SmtpPort": 465,
"SmtpUseSsl": true,
"UseOAuth2": false
}
]
}
}