Compare commits

...

5 Commits

Author SHA1 Message Date
Ompragash Viswanathan 5b0a93b192 fix: use WithTLSPolicy instead of WithTLSPortPolicy to preserve user-configured SMTP port
WithTLSPortPolicy calls SetTLSPortPolicy, which checks `c.port == DefaultPort`
(25) to decide whether the port was explicitly set or left as default. When a
user configures port 25 — common for internal relay hosts that accept plaintext
SMTP — the guard condition evaluates true and the library silently overrides the
port to 587 (DefaultPortTLS) with a fallback to 25.

This causes a two-stage failure in environments where port 587 is unreachable:

  1. The primary dial to host:587 blocks for the full 15-second connection
     timeout (go-mail DefaultTimeout) waiting on a firewalled port.
  2. The fallback dial to host:25 fires with an already-expired context,
     producing a misleading "lookup <host>: i/o timeout" DNS error rather
     than the actual root cause (port 587 unreachable).

The previous mail library (gopkg.in/mail.v2) used the port value directly
without any policy-based override, so this regression surfaced only after
migrating to github.com/wneessen/go-mail.

WithTLSPolicy applies the same STARTTLS negotiation semantics (NoTLS or
TLSOpportunistic) without mutating the port, which is the correct choice
when the caller has already provided an explicit port via WithPort.
2026-02-17 19:30:07 +05:30
OP (oppenheimer) b4bc696ee8 Merge pull request #5 from harness-community/doc_add
feat:[]: adding documentation for sample test pipeline
2025-10-16 11:35:25 +05:30
Ebtasam Faridy 62bbef39fa feat:[]: adding documentation for sample test pipeline 2025-10-16 10:39:51 +05:30
ebtasam-faridy 75db7ad3f8 Merge pull request #4 from harness-community/CI-18739
feat: [CI-18739]: migrate to Go 1.24 with modern dependencies and Go modules
2025-10-15 12:38:00 +05:30
Ompragash Viswanathan f5c31387a1 Fix the Default Email Template to use helper 2025-10-15 11:11:07 +05:30
3 changed files with 56 additions and 4 deletions
+49
View File
@@ -73,6 +73,55 @@ drone secret add \
See [Secret Guide](https://docs.drone.io/secret/) for additional information on secrets.
### Harness CI Plugin Step
When using this plugin in Harness CI pipelines, you can configure it as a Plugin step. The plugin automatically uses DRONE_* environment variables provided by the Harness CI environment for build context (repository, commit, build status, etc.).
```yaml
pipeline:
orgIdentifier: default
tags: {}
stages:
- stage:
name: Run Plugin
identifier: Email_Notification
description: ""
type: CI
spec:
cloneCodebase: false
platform:
os: Windows
arch: Amd64
runtime:
type: Cloud
spec: {}
execution:
steps:
- step:
type: Plugin
name: Email Plugin
identifier: Email_Plugin
spec:
connectorRef: emailtestdocker
image: plugins/email:3.1.0-debug
settings:
from.address: from@example.com
from.name: Magic Elves
host: sandbox.smtp.mailtrap.io
username: <+secrets.getValue("smtp_username")>
password: <+secrets.getValue("smtp_password")>
recipients: user@example.com
port: "2525"
caching:
enabled: false
paths: []
buildIntelligence:
enabled: false
projectIdentifier: example_project
identifier: email_notification_pipeline
name: Email Notification Pipeline
```
### Custom Templates
In some cases you may want to customize the look and feel of the email message
+2 -2
View File
@@ -191,7 +191,7 @@ const DefaultTemplate = `
<div class="content">
<table class="main" width="100%" cellpadding="0" cellspacing="0">
<tr>
{{#success build.status}}
{{#equal build.status "success"}}
<td class="alert alert-good">
<a href="{{ build.link }}">
Successful build #{{ build.number }}
@@ -203,7 +203,7 @@ const DefaultTemplate = `
Failed build #{{ build.number }}
</a>
</td>
{{/success}}
{{/equal}}
</tr>
<tr>
<td class="content-wrap">
+5 -2
View File
@@ -185,10 +185,13 @@ func (p Plugin) Exec() error {
}
// Handle STARTTLS policy
// Note: Use WithTLSPolicy (not WithTLSPortPolicy) to avoid overriding
// the user-configured port. WithTLSPortPolicy treats port 25 as "default/unset"
// and silently changes it to 587 for TLSOpportunistic/TLSMandatory.
if p.Config.NoStartTLS {
options = append(options, mail.WithTLSPortPolicy(mail.NoTLS))
options = append(options, mail.WithTLSPolicy(mail.NoTLS))
} else {
options = append(options, mail.WithTLSPortPolicy(mail.TLSOpportunistic))
options = append(options, mail.WithTLSPolicy(mail.TLSOpportunistic))
}
client, err := mail.NewClient(p.Config.Host, options...)