Orchard Core Azure Communication Services Email
OrchardCore.Email.Azure provides Azure Communication Services delivery on top
of the provider-neutral OrchardCore.Email API.
- The tenant provider is
AzureEmailProvider, technical nameAzure. - The configuration-backed provider is
DefaultAzureEmailProvider, technical nameDefaultAzure. - Application code sends through
IEmailServiceand can therefore remain independent of the chosen provider.
Enable the features, configure a verified sender and connection string under
Settings → Communication → Email, then select Azure as the default when
multiple providers are enabled.
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Email",
"OrchardCore.Email.Azure"
]
},
{
"name": "Settings",
"AzureEmailSettings": {
"IsEnabled": true,
"DefaultSender": "DoNotReply@your-domain.azurecomm.net",
"ConnectionString": "supply-from-a-secure-source"
},
"EmailSettings": {
"DefaultProviderName": "Azure"
}
}
]
}
DefaultAzureEmailOptions binds
OrchardCore_Email_AzureCommunicationServices; it creates DefaultAzure
when its sender and connection string are valid. Keep ACS connection strings
out of committed recipes.
using OrchardCore.Email;
using OrchardCore.Infrastructure;
namespace MyModule;
public sealed class WelcomeEmailService
{
private readonly IEmailService _emailService;
public WelcomeEmailService(IEmailService emailService)
{
_emailService = emailService;
}
public Task<Result> SendAsync(string recipient)
{
return _emailService.SendAsync(new MailMessage
{
To = recipient,
Subject = "Welcome",
TextBody = "Welcome to the site.",
});
}
}
Use Tools → Testing → Email Test to test an enabled provider. Confirm the sender identity, service restrictions, and quota in Azure before production use.