diff --git a/src/OrchardCore.Build/Dependencies.props b/src/OrchardCore.Build/Dependencies.props
index 4cf73ff5c86..ec37e256c61 100644
--- a/src/OrchardCore.Build/Dependencies.props
+++ b/src/OrchardCore.Build/Dependencies.props
@@ -70,6 +70,7 @@
+
diff --git a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/OrchardCore.Email.Smtp.csproj b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/OrchardCore.Email.Smtp.csproj
index c80c6b4672c..8d0f96dc977 100644
--- a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/OrchardCore.Email.Smtp.csproj
+++ b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/OrchardCore.Email.Smtp.csproj
@@ -22,6 +22,7 @@
+
@@ -29,6 +30,7 @@
+
diff --git a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpOptionsConfiguration.cs b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpOptionsConfiguration.cs
index 0ac92e3870f..6d5b2d24384 100644
--- a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpOptionsConfiguration.cs
+++ b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpOptionsConfiguration.cs
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
+using OrchardCore.Mappings;
using OrchardCore.Settings;
namespace OrchardCore.Email.Smtp.Services;
@@ -29,20 +30,7 @@ public void Configure(SmtpOptions options)
.GetAwaiter().GetResult()
.As();
- options.DefaultSender = settings.DefaultSender;
- options.DeliveryMethod = settings.DeliveryMethod;
- options.PickupDirectoryLocation = settings.PickupDirectoryLocation;
- options.Host = settings.Host;
- options.Port = settings.Port;
- options.ProxyHost = settings.ProxyHost;
- options.ProxyPort = settings.ProxyPort;
- options.EncryptionMethod = settings.EncryptionMethod;
- options.AutoSelectEncryption = settings.AutoSelectEncryption;
- options.RequireCredentials = settings.RequireCredentials;
- options.UseDefaultCredentials = settings.UseDefaultCredentials;
- options.UserName = settings.UserName;
- options.Password = settings.Password;
- options.IgnoreInvalidSslCertificate = settings.IgnoreInvalidSslCertificate;
+ options = SmtpSettingsMapper.Map(settings);
if (!string.IsNullOrWhiteSpace(settings.Password))
{
diff --git a/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpSettingsMapper.cs b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpSettingsMapper.cs
new file mode 100644
index 00000000000..fba02b98457
--- /dev/null
+++ b/src/OrchardCore.Modules/OrchardCore.Email.Smtp/Services/SmtpSettingsMapper.cs
@@ -0,0 +1,9 @@
+using Riok.Mapperly.Abstractions;
+
+namespace OrchardCore.Email.Smtp.Services;
+
+[Mapper]
+public static partial class SmtpSettingsMapper
+{
+ public static partial SmtpOptions Map(SmtpSettings source);
+}
diff --git a/src/OrchardCore/OrchardCore.Infrastructure.Abstractions/Mappings/IMapper.cs b/src/OrchardCore/OrchardCore.Infrastructure.Abstractions/Mappings/IMapper.cs
new file mode 100644
index 00000000000..1e0100f3a05
--- /dev/null
+++ b/src/OrchardCore/OrchardCore.Infrastructure.Abstractions/Mappings/IMapper.cs
@@ -0,0 +1,24 @@
+namespace OrchardCore.Mappings;
+
+///
+/// Represents a contract for mapping objects.
+///
+public interface IMapper
+{
+ ///
+ /// Maps the specified source object to a new object of the specified destination type.
+ ///
+ /// The type of object to map to.
+ /// The object to be mapped.
+ TDestination Map(object source);
+
+ ///
+ /// Maps the specified source object to the specified destination object.
+ ///
+ ///
+ ///
+ /// The object to be mapped.
+ /// The object to map to.
+ ///
+ TDestination Map(TSource source, TDestination destination);
+}
diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Mappings/ObjectMapper.cs b/src/OrchardCore/OrchardCore.Infrastructure/Mappings/ObjectMapper.cs
new file mode 100644
index 00000000000..fcc7c5ee005
--- /dev/null
+++ b/src/OrchardCore/OrchardCore.Infrastructure/Mappings/ObjectMapper.cs
@@ -0,0 +1,12 @@
+using Riok.Mapperly.Abstractions;
+
+namespace OrchardCore.Mappings;
+
+///
+/// Represents a service for mapping objects.
+///
+[Mapper]
+public static partial class ObjectMapper
+{
+ public static partial TTarget Map(TSource source);
+}
diff --git a/src/OrchardCore/OrchardCore.Infrastructure/OrchardCore.Infrastructure.csproj b/src/OrchardCore/OrchardCore.Infrastructure/OrchardCore.Infrastructure.csproj
index d0701e3871d..9448012b1d1 100644
--- a/src/OrchardCore/OrchardCore.Infrastructure/OrchardCore.Infrastructure.csproj
+++ b/src/OrchardCore/OrchardCore.Infrastructure/OrchardCore.Infrastructure.csproj
@@ -16,6 +16,7 @@
+