Octopus.Script exported 2025-10-12 by mcasperson belongs to ‘Octopus’ category.
Checks that the SMTP server has been configured.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Octopus API Key
SmtpCheck.Octopus.Api.Key =
The API key used to access the Octopus instance
Script body
Steps based on this template will execute the following PowerShell script.
$apiKey = "#{SmtpCheck.Octopus.Api.Key}"
$isSmtpConfigured = $false
if (![string]::IsNullOrWhitespace($apiKey) -and $apiKey.StartsWith("API-"))
{
if ([String]::IsNullOrWhitespace("#{Octopus.Web.ServerUri}"))
{
$octopusUrl = "#{Octopus.Web.BaseUrl}"
}
else
{
$octopusUrl = "#{Octopus.Web.ServerUri}"
}
$uriBuilder = New-Object System.UriBuilder("$octopusUrl/api/smtpconfiguration/isconfigured")
$uri = $uriBuilder.ToString()
try
{
$headers = @{ "X-Octopus-ApiKey" = $apiKey }
$smtpConfigured = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers
$isSmtpConfigured = $smtpConfigured.IsConfigured
}
catch
{
Write-Host "Error checking SMTP configuration: $($_.Exception.Message)"
}
}
else
{
Write-Highlight "The project variable SmtpCheck.Octopus.Api.Key has not been configured, unable to check SMTP configuration."
}
if (-not $isSmtpConfigured)
{
Write-Highlight "SMTP is not configured. Please [configure SMTP](https://octopus.com/docs/projects/built-in-step-templates/email-notifications#smtp-configuration) settings in Octopus Deploy."
}
Set-OctopusVariable -Name SmtpConfigured -Value $isSmtpConfigured
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "ad8126be-37af-4297-b46e-fce02ba3987a",
"Name": "Octopus - Check SMTP Server Configured",
"Description": "Checks that the SMTP server has been configured.",
"Version": 1,
"ExportedAt": "2025-10-12T23:48:48.086Z",
"ActionType": "Octopus.Script",
"Author": "mcasperson",
"Packages": [],
"Parameters": [
{
"Id": "d48a2f7f-f895-459a-ae63-e81c8eb24d43",
"Name": "SmtpCheck.Octopus.Api.Key",
"Label": "Octopus API Key",
"HelpText": "The API key used to access the Octopus instance",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "Sensitive"
}
}
],
"Properties": {
"OctopusUseBundledTooling": "False",
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "$apiKey = \"#{SmtpCheck.Octopus.Api.Key}\"\n$isSmtpConfigured = $false\n\nif (![string]::IsNullOrWhitespace($apiKey) -and $apiKey.StartsWith(\"API-\"))\n{\n if ([String]::IsNullOrWhitespace(\"#{Octopus.Web.ServerUri}\"))\n {\n $octopusUrl = \"#{Octopus.Web.BaseUrl}\"\n }\n else\n {\n $octopusUrl = \"#{Octopus.Web.ServerUri}\"\n }\n\n $uriBuilder = New-Object System.UriBuilder(\"$octopusUrl/api/smtpconfiguration/isconfigured\")\n $uri = $uriBuilder.ToString()\n\n try\n {\n $headers = @{ \"X-Octopus-ApiKey\" = $apiKey }\n $smtpConfigured = Invoke-RestMethod -Method Get -Uri $uri -Headers $headers\n $isSmtpConfigured = $smtpConfigured.IsConfigured\n }\n catch\n {\n Write-Host \"Error checking SMTP configuration: $($_.Exception.Message)\"\n }\n}\nelse\n{\n Write-Highlight \"The project variable SmtpCheck.Octopus.Api.Key has not been configured, unable to check SMTP configuration.\"\n}\n\nif (-not $isSmtpConfigured)\n{\n Write-Highlight \"SMTP is not configured. Please [configure SMTP](https://octopus.com/docs/projects/built-in-step-templates/email-notifications#smtp-configuration) settings in Octopus Deploy.\"\n}\n\nSet-OctopusVariable -Name SmtpConfigured -Value $isSmtpConfigured"
},
"Category": "Octopus",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/a381802920158308/step-templates/octopus-smtp-server-configured.json",
"Website": "/step-templates/ad8126be-37af-4297-b46e-fce02ba3987a",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbW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