Skip to content

Mail.json

Cautions

When changing parameters, please refer to "Confirmation When Changing Parameters".

Setting Values

The setting values for this parameter file are as follows.

Parameter name e.g. Description
SmtpHost "smtp.example.com" Specify the address of the SMTP server.
SmtpPort 25 Specify the port of the SMTP server.
SmtpUserName "UserName" Specify the user name for SMTP-AUTH. Specify null if user authentication is not performed.
SmtpPassword "Password" Specify the password for SMTP-AUTH. Specify null if user authentication is not performed.
Parameter name e.g. Description
SmtpHost "smtp.sendgrid.net" Specify the address of SendGrid.
SmtpPort 0 No setting required if using SendGrid.
SmtpUserName "apikey" Specify "apikey" (fixed value).
SmtpPassword "SG.xxxxxxx" Specify the API key of SendGrid.
Example of configuring Mail.json for SendGrid
"SmtpHost": "smtp.sendgrid.net",
"SmtpPort": 0,
"SmtpUserName": "apikey",
"SmtpPassword": "SG.xxxxAPIKeyxxxxxx...",

Settings required to send email using OAuth 2.0 authentication

Refer to "Configure Pleasanter to send mail using the SMTP server of M365".

Common Settings

Parameter name e.g. Description
SmtpEnableSsl false Specify true to enable SSL/TLS. If set to true, the StartTls encryption method will be applied. If you want to specify a different method, use the SecureSocketOptions Parameter.
ServerCertificateValidationCallback false Specify true to suppress the error "An error occurred while attempting to establish an SSL or TLS connection".
SecureSocketOptions "SslOnConnect" Specify the SSL/TLS encryption method to use for the connection. The default value is null. For allowed strings, refer to Enum Names available in MimeKit.
FixedFrom "fixed@example.com" If an email address is specified, this will be the from address when sending an email. If null is set, the logged-in user's email address will be the from address.
AllowedFrom ["support@example.com"] If FixedFrom is not null and corresponds to an email address listed in AllowedFrom, FixedFrom will not be used and the email address of the logged-in user will be the from.
SupportFrom "support@example.com" Specify a support email address. Required when using "Enable 2-step Authentication by Email".
InternalDomains ".example1.com,.example2.com" If you want to restrict the domains to which emails can be sent, specify a whitelist separated by commas.
AddressValidation "\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]+\b" Specify the regular expression used to validate email addresses.
Encoding "shift_jis" The default value is null. Specify explicitly if you want to change it to something other than UTF-8. If the system does not support the encoding name, an error will be output to SysLogs when the settings are loaded, and then sending will be attempted in UTF-8.
ContentEncoding "SevenBit" The default value is null. For permitted strings, refer to Enum Names available in MimeKit.

How to Register in System Environment Variables

SmtpUserName, SmtpPassword, OAuthClientId, OAuthClientSecret, SendGrid.ApiKey, AwsSes.AccessKeyId, AwsSes.SecretAccessKey, and AwsSes.SessionToken can be registered in system environment variables. OAuthClientId and OAuthClientSecret can be registered in 1.5.1.0 and later, and SendGrid.ApiKey, AwsSes.AccessKeyId, AwsSes.SecretAccessKey, and AwsSes.SessionToken in 1.5.5.0 and later.

For OAuthClientId and OAuthClientSecret, also refer to "Configure Pleasanter to send mail using the SMTP server of M365".

Registering in system environment variables

Also refer to the following page for registration in system environment variables.
Register Credentials in System Environment Variables

1. Naming Convention

The naming convention of the system environment variables is as follows.

(Service name)_Mail_SmtpUserName
(Service name)_Mail_SmtpPassword
(Service name)_Mail_OAuthClientId
(Service name)_Mail_OAuthClientSecret
(Service name)_Mail_SendGrid_ApiKey
(Service name)_Mail_AwsSes_AccessKeyId
(Service name)_Mail_AwsSes_SecretAccessKey
(Service name)_Mail_AwsSes_SessionToken
Column Required Description
Service name ○ Specify "EnvironmentName" or "Name" in Service.json

You can also set these values in this parameter file as before. For Azure, you can add or edit them via [App Service Settings] -> [Configuration] -> [Application Settings].

Example Settings

Variable Example
Implem.Pleasanter_Mail_SmtpUserName UserName
Implem.Pleasanter_Mail_SmtpPassword Password
Implem.Pleasanter_Mail_OAuthClientId ClientId
Implem.Pleasanter_Mail_OAuthClientSecret ClientSecret
Implem.Pleasanter_Mail_SendGrid_ApiKey SG.xxxxAPIKeyxxxxxx...
Implem.Pleasanter_Mail_AwsSes_AccessKeyId AccessKeyId
Implem.Pleasanter_Mail_AwsSes_SecretAccessKey SecretAccessKey
Implem.Pleasanter_Mail_AwsSes_SessionToken SessionToken

2. Priority Order

If a value is set in both this parameter file and the system environment, or if it is set in an abbreviated form, the priority is as follows.

Priority order Setting value
1 "SmtpUserName" in this parameter file
2 "(Service name: EnvironmentName)_Mail_SmtpUserName" in the environment variable
3 "(Service name: Name)_Mail_SmtpUserName" in the environment variable
Priority order Setting value
1 "SmtpPassword" in this parameter file
2 "(Service name: EnvironmentName)_Mail_SmtpPassword" in the environment variable
3 "(Service name: Name)_Mail_SmtpPassword" in the environment variable
Priority order Setting value
1 "OAuthClientId" in this parameter file
2 "(Service name: EnvironmentName)_Mail_OAuthClientId" in the environment variable
3 "(Service name: Name)_Mail_OAuthClientId" in the environment variable
Priority order Setting value
1 "OAuthClientSecret" in this parameter file
2 "(Service name: EnvironmentName)_Mail_OAuthClientSecret" in the environment variable
3 "(Service name: Name)_Mail_OAuthClientSecret" in the environment variable
Priority order Setting value
1 "SendGrid.ApiKey" in this parameter file
2 "(Service name: EnvironmentName)_Mail_SendGrid_ApiKey" in the environment variable
3 "(Service name: Name)_Mail_SendGrid_ApiKey" in the environment variable
4 The value of "SmtpPassword" in this parameter file (only when SmtpHost is "smtp.sendgrid.net" and Provider is "Smtp". The value of SmtpPassword is determined as described in "SmtpPassword Priority Order")
Priority order Setting value
1 "AwsSes.AccessKeyId" in this parameter file
2 "(Service name: EnvironmentName)_Mail_AwsSes_AccessKeyId" in the environment variable
3 "(Service name: Name)_Mail_AwsSes_AccessKeyId" in the environment variable
Priority order Setting value
1 "AwsSes.SecretAccessKey" in this parameter file
2 "(Service name: EnvironmentName)_Mail_AwsSes_SecretAccessKey" in the environment variable
3 "(Service name: Name)_Mail_AwsSes_SecretAccessKey" in the environment variable
Priority order Setting value
1 "AwsSes.SessionToken" in this parameter file
2 "(Service name: EnvironmentName)_Mail_AwsSes_SessionToken" in the environment variable
3 "(Service name: Name)_Mail_AwsSes_SessionToken" in the environment variable

3. Notes When Registering in System Environment Variables

As described in "2. Priority Order", the value set in the parameter file takes the highest priority. Therefore, when you register a value in a system environment variable, specify "null" in the parameter file.

Supported Versions

Supported versions Body
1.3.18.0 and later Added ServerCertificateValidationCallback
1.3.49.0 and later Added SecureSocketOptions