Set Up to Send Emails from Pleasanter with SendGrid
Overview¶
This page explains how to set up email sending with the SendGrid Web API so that Pleasanter can send emails with reminders and notifications.
Cautions¶
- From version 1.5.5.0, the configuration method has changed with the addition of the Provider parameter. To migrate an existing environment, refer to "About Migrating Email Sending Provider Settings".
- When changing parameters, check "Confirmation When Changing Parameters".
- For security reasons, we recommend setting the API key in an environment variable instead of writing it directly in Mail.json. For details, refer to "2. Setting with Environment Variables (Recommended)" in "Operation Procedure".
- After changing the settings in "Mail.json", you need to restart Pleasanter. The changes are not applied until you restart it.
Prerequisites¶
- Prepare a SendGrid API key.
- Make sure that the email address or domain used as the sender has been verified with Sender Authentication in SendGrid.
Operation Procedure¶
1. Set Mail.json¶
Edit the configuration file Mail.json and specify SendGrid for Provider. Also, set your SendGrid API key to ApiKey in the SendGrid section.
{
"Provider": "SendGrid",
"SendGrid": {
"ApiKey": "SG.xxxxAPIKEYxxxxxx..."
},
"FixedFrom": "noreply@example.com",
"SupportFrom": "\"Support\" <support@example.com>"
}
Description of the Settings¶
| Parameter | Example | Description |
|---|---|---|
| Provider | "SendGrid" | Specify SendGrid to use SendGrid. |
| SendGrid.ApiKey | "SG.xxxxAPIKEYxxxxxx..." | Specify your SendGrid API key. To set it in an environment variable instead, specify an empty string ("") or null. |
| FixedFrom | "noreply@example.com" | Specify the from address for sending emails. |
| SupportFrom | "\"Support\" \<support@example.com>" | Specify the email address for support. |
For details of each parameter, refer to Mail.json.
2. Setting with Environment Variables (Recommended)¶
You can set the SendGrid API key in an environment variable instead of Mail.json. If a value is specified in Mail.json, that value takes precedence.
Pleasanter reads the value from the environment variable only when the value in Mail.json is empty ("") or null.
Corresponding Environment Variables¶
| Target Parameter | Environment Variable Name (EnvironmentName Format) | Environment Variable Name (ServiceName Format) |
|---|---|---|
| SendGrid.ApiKey | {EnvironmentName}_Mail_SendGrid_ApiKey | {ServiceName}_Mail_SendGrid_ApiKey |
{EnvironmentName} and {ServiceName} correspond to the values of the EnvironmentName and ServiceName parameters in Service.json. The default ServiceName is Pleasanter.
Setting in PowerShell (Windows)¶
Setting in bash (Linux or macOS)¶
3. Restart Pleasanter¶
Restart Pleasanter to apply the changes.
In a Windows environment, restart IIS.
In a Linux environment, restart the service with the following command.
In a Microsoft Azure environment, restart the App Service.
Supported Versions¶
| Supported versions | Body |
|---|---|
| 1.3.18.0 and later | Supported sending emails with SendGrid (by specifying SmtpHost) |
| 1.5.5.0 and later | Added the following parameters ・Provider ・ApiKey |