Skip to content

SMTP Configuration#

The Janssen Server provides multiple configuration tools to perform these tasks.

Use the command line to perform actions from the terminal. Learn how to use Jans CLI here or jump straight to the Using Command Line

Use a fully functional text-based user interface from the terminal. Learn how to use Jans Text-based UI (TUI) here or jump straight to the Using Text-based UI

Use REST API for programmatic access or invoke via tools like CURL or Postman. Learn how to use Janssen Server Config API here or Jump straight to the Using Configuration REST API

Using Command Line#

In the Janssen Server, you can deploy and customize the SMTP using the command line. To get the details of Janssen command line operations relevant to SMTP Configuration, you can check the operations under ConfigurationSmtp task using the command below:

Command
jans cli --info ConfigurationSmtp
Sample Output
Operation ID: get-config-smtp
 Description: Returns SMTP server configuration
Operation ID: put-config-smtp
 Description: Updates SMTP server configuration
 Schema: SmtpConfiguration
Operation ID: post-config-smtp
 Description: Adds SMTP server configuration
 Schema: SmtpConfiguration
Operation ID: delete-config-smtp
 Description: Deletes SMTP server configuration
Operation ID: test-config-smtp
 Description: Signing Test SMTP server configuration
 Schema: SmtpTest

Find SMTP Server Configuration#

To view the current SMTP server configuration, run the following command line:

Command
jans cli --operation-id get-config-smtp

It will show the SMTP server configuration as below:

Sample Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
{
  "valid": false,
  "port": 0,
  "trust_host": false,
  "requires_authentication": false,
  "key_store": "/etc/certs/smtp-keys.pkcs12",
  "key_store_password": "kb5JITTrmCyX1LNEp8uorA==",
  "key_store_alias": "smtp_sig_ec256",
  "signing_algorithm": "SHA256withECDSA"
}

Setup New SMTP Server Configuration#

To add a new SMTP Server, we can use post-config-smtp operation id. As shown in the output for--info command, the post-config-smtp operation requires data to be sent according to the SmtpConfiguration schema.

To see the schema, use the command below:

Command
jans cli --schema SmtpConfiguration 

The Janssen Server also provides an example of data that adheres to the above schema. To fetch the example, use the command below.

Command
jans cli --schema-sample SmtpConfiguration 

Using the schema and the example above, we have added below data to the file /tmp/smtp.json.

Input
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{
  "valid": true,
  "host": "string",
  "port": 5,
  "connect_protection": "StartTls",
  "trust_host": false,
  "from_name": "jans",
  "from_email_address": "string",
  "requires_authentication": false,
  "smtp_authentication_account_username": "string",
  "smtp_authentication_account_password": "string",
  "key_store": "string",
  "key_store_password": "string",
  "key_store_alias": "string",
  "signing_algorithm": "string"
}

To setup a new SMTP server configuration, run the following command:

Command
jans cli --operation-id post-config-smtp \
--data /tmp/smtp.json
Sample Output
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
{
  "valid": true,
  "host": "string",
  "port": 5,
  "connect_protection": "StartTls",
  "trust_host": false,
  "from_name": "jans",
  "from_email_address": "string",
  "requires_authentication": false,
  "smtp_authentication_account_username": "string",
  "smtp_authentication_account_password": "CGmVqM6v4Hs=",
  "key_store": "string",
  "key_store_password": "CGmVqM6v4Hs=",
  "key_store_alias": "string",
  "signing_algorithm": "string"
}

Update SMTP Server Configuration#

To update the SMTP server, we can use the put-config-smtp operation id. simply change any information on /tmp/smtp.jsonfile and run the following command:

In that file, update the value false to true of the trust_host field.

Command
jans cli --operation-id put-config-smtp \
--data /tmp/smtp.json
It will update the information.

Delete SMTP Sever Configuration#

To delete the SMTP Sever, we can use the delete-config-smtp operation id. run the following command

Command
jans cli --operation-id delete-config-smtp

Test SMTP Server Configuration#

Testing SMTP Server configuration token with https://jans.io/oauth/config/smtp.write scope is required. To test the SMTP server configuration update, change any information on the /tmp/smtp.json file with test data and run the following command:

Command
jans cli --operation-id test-config-smtp \
--data /tmp/smtp.json
This will return status code 200 with a response as true or false based on the SMTP test result. Note: SMTP Password should be an App password and not a web login password.

Using Text-based UI#

Start TUI using the command below:

Command
jans tui

SMPT Screen#

Navigate to Auth Server -> SMPT to open the SMPT screen as shown in the image below.

image

  • This screen shows the current SMTP server configuration.
  • After changing the SMPT data, update the SMPT server using the Save button.
  • Test the SMPTS server using the Test button, and the result will be displayed.

The test result image is shown below.

image

Using Configuration REST API#

Janssen Server Configuration REST API exposes relevant endpoints for managing and configuring the SMTP. Endpoint details are published in the Swagger document.


Last update: 2024-10-29
Created: 2021-04-22