Skip to content

Setting up authentication with SMTP

The Standard SMTP mail sender signs in to your SMTP server with a user name and password it reads from the application's configuration, never from the e-mail settings in Veva. Set one pair for all mail, a pair per from address, or both.

Settings and credentials

The Standard SMTP mail sender comes from the Veva.Modules.Mail.MailKitMailer package. Its settings in Veva are SMTP server host, SMTP server port, Default from name, Default from address and Enable SSL. Enable SSL connects with STARTTLS, so set the port your server offers it on, usually 587.

The user name and password are not settings. The sender reads them from the MailKit section of the application's configuration each time it sends a message, so they can live in appsettings.json, user secrets, environment variables or a key vault, like any ASP.NET Core configuration. It signs in only when it finds both a user name and a password. Otherwise it sends without authentication.

One pair for all mail

{
  "MailKit": {
    "UserName": "<username>",
    "Password": "<password>"
  }
}

In environment variables, join the section and the key with a double underscore: MailKit__UserName and MailKit__Password.

A pair per from address

Prefix the keys with the from address and an underscore. The from address is the one the message is sent from, or the Default from address when the message names none. With only these keys, mail from any other address is sent without authentication.

{
  "MailKit": {
    "sender@example.com_UserName": "<username>",
    "sender@example.com_Password": "<password>"
  }
}

Combine the two to set a default pair and override it for some from addresses. A key for the from address wins over the default:

{
  "MailKit": {
    "UserName": "<default username>",
    "Password": "<default password>",
    "sender@example.com_UserName": "<username for this address>",
    "sender@example.com_Password": "<password for this address>"
  }
}

Keys without @ and dots

Some configuration stores do not accept @ or . in a key name; Azure Key Vault secret names, for one, allow only letters, digits and dashes. For those, Veva also reads the from address with @ written as -at- and each . as -, joined to the key with a dash:

{
  "MailKit": {
    "sender-at-example-com-UserName": "<username>",
    "sender-at-example-com-Password": "<password>"
  }
}

Veva reads this form only when neither sender@example.com_UserName nor a default UserName is set, and it looks the password up the same way.

Back to top

Type to search the docs, components and API.

↑↓ to move ↵ to open Esc to close Search by Veva