Skip to content

The Azure Function used by my blog (https://edi.wang) to send email notifications

License

Notifications You must be signed in to change notification settings

EdiWang/Moonglade.Email

Repository files navigation

Moonglade.Email

The Azure Function used by my blog (https://edi.wang) to send notifications.

This Function sets HTML template and send email notifications to blog administrator or users.

Tools Alternative
.NET 8.0 SDK N/A
Visual Studio 2022 with Azure Development payload Visual Studio Code
Azure Key Vault N/A
Azure CLI N/A

You can choose to send email by SMTP or Azure Communication Service.

Send by Azure Communication Service

This option is in preview and may subject to change.

  • Setup Azure CLI and login to your Azure subscription first.
  • Create an Azure Communication Service resource with Email service enabled in Azure Portal.
  • Run "\Deployment\DeployACS.ps1" to setup the Azure Function App.

Parameters example:

-regionName "westus"
-rsgName "moonglade-test-group"
-storageAccountName "moongladeteststorage"
-emailDisplayName "Moonglade Notification Test"
-azureCommunicationConnection "<your connection string>"
-azureCommunicationSenderAddress "<your sender address>"
  • Build and deploy Moonglade.Notification.sln to the Azure Function.

Send by SMTP

Please note, only basic authentication is supported in this mode. Microsoft 365 has disabled basic authentication, so this won't work with your Microsoft 365 enterprise or personal account.

  • Setup Azure CLI and login to your Azure subscription first.
  • Run "\Deployment\DeploySMTP.ps1" to setup the Azure Function App and Azure Key Vault.

Parameters example:

-regionName "westus"
-rsgName "moonglade-test-group"
-storageAccountName "moongladeteststorage"
-emailDisplayName "Moonglade Notification Test"
-smtpServer "smtp.example.com"
-smtpUserName "[email protected]"
-pwdValue "P@ssw0rd"
  • Build and deploy Moonglade.Notification.sln to the Azure Function.

Configure Moonglade

Open appsettings.json under your Moonglade instance, add the following settings:

"Email": {
  "ApiEndpoint": "https://yourfunctionappurl",
  "ApiKey": "<your function key>"
}

Local Development and Debugging

For development, create local.settings.json under "./src/Moonglade.Function.Email", this file defines development time settings. It is by default ignored by git, so you will need to manange it on your own.

Sample local.settings.json file (SMTP)

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "moongladestorage": "<storage account connection string>",
    "EmailDisplayName": "Moonglade Notification Azure Function (local)",
    "Sender": "smtp",
    "EnableSsl": true,
    "SmtpServerPort": 25,
    "SmtpServer": "smtp.example.com",
    "SmtpUserName": "[email protected]",
    "EmailAccountPassword": "<smtp password>"
  }
}

Sample local.settings.json file (Azure Communication)

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    "moongladestorage": "<storage account connection string>",
    "EmailDisplayName": "Moonglade Notification Azure Function (local)",
    "Sender": "AzureCommunication",
    "AzureCommunicationConnection": "<your connection string>",
    "AzureCommunicationSenderAddress": "<your sender address>"
  }
}

免责申明

对于中国访客,我们有一份特定的免责申明。请确保你已经阅读并理解其内容:

About

The Azure Function used by my blog (https://edi.wang) to send email notifications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published