smtp://¶
SMTP producer. Uses
Go stdlib net/smtp + mime/multipart. For TLS-from-the-start
endpoints use smtps://. For receive, see
imap:// / imaps:// /
pop3:// / pop3s://.
URI shape¶
host is the URI path segment (or ?host=…). Default port 587
(smtp). Default to, cc, etc. can be set on the URI; per-request
headers override.
Parameters¶
Connection¶
| Param | Type | Default | Description |
|---|---|---|---|
host |
string | from URI path | SMTP server host. |
port |
integer | 587 |
SMTP server port. |
username |
string | — | SMTP AUTH username. |
password |
string | — | SMTP AUTH password. |
authMechanism |
enum | plain |
plain (AUTH PLAIN) or login (AUTH LOGIN). Office 365 rejects PLAIN with 504 5.7.4 and requires login. Credentials are sent only over TLS/STARTTLS. |
connectionTimeout |
duration | 30s |
TCP dial timeout. |
Header defaults (overridable per-message)¶
| Param | Type | Default | Description |
|---|---|---|---|
from |
string | — | Default From: address. |
to |
string | — | Default To: (CSV). |
cc |
string | — | Default Cc: (CSV). |
bcc |
string | — | Default Bcc: (envelope-only). |
replyTo |
string | — | Default Reply-To: address. |
subject |
string | — | Default Subject:. |
contentType |
string | text/plain; charset=UTF-8 |
Default body content type. |
useInlineAttachments |
boolean | false |
Build multipart/related so HTML body can reference cid:<name> images. |
alternativeBodyHeader |
string | HelixMailAlternativeBody |
Header that supplies the plain-text alternative when the body is HTML. |
TLS¶
| Param | Type | Default | Description |
|---|---|---|---|
tls |
boolean | false (smtp), true (smtps) |
Implicit TLS from connection start. |
starttls |
boolean | false |
Opportunistic STARTTLS upgrade. |
tlsInsecure |
boolean | false |
Skip certificate verification (testing only). |
tlsServerName |
string | — | SNI server name override. |
tlsCert / tlsKey / tlsCA |
string | — | Client cert + key + CA bundle. |
Body shape¶
The In body becomes the message body. Set the message shape via the exchange:
- Plain text: body is
stringor[]byte;Content-Typedefaults totext/plain; charset=UTF-8. - HTML: set the
Content-Typeheader totext/html; charset=UTF-8. WhenHelixMailAlternativeBodyis also set, the producer buildsmultipart/alternative(plain + HTML). - Attachments: set the
Attachmentsheader tomap[string][]byte. The producer wraps the body inmultipart/mixed. - Inline images (when
useInlineAttachments=true): setInlineAttachmentsheader tomap[string][]byte. HTML body references each image as<img src="cid:<filename>">. Wraps inmultipart/related.
Header conventions¶
| Header | Direction |
|---|---|
HelixMailContentType |
Read |
HelixMailAlternativeBody |
Read |
HelixMailMessageId |
Written on success |
Standard headers (Subject, From, To, Cc, Bcc, Reply-To) |
Read |
Attachments (map[string][]byte) |
Read |
Examples¶
Plain text¶
- to: smtp://mail.example.com:587?from=ops@example.com&username=ops&password=…&starttls=true
# body: "Hello Helix!" To header set on the exchange
Office 365 (AUTH LOGIN)¶
Office 365 rejects AUTH PLAIN — use authMechanism=login over STARTTLS:
- to: "smtp://smtp.office365.com:587?from=svc@contoso.com&username=svc@contoso.com&password=${env:O365_PASSWORD}&authMechanism=login&starttls=true"
# To / Subject set on the exchange; body is the message text.
HTML + plain alt¶
- to: smtp://mail.example.com?from=alerts@example.com
# body: "<p>Hello</p>"
# headers:
# Content-Type: text/html; charset=UTF-8
# HelixMailAlternativeBody: "Hello"
Attachment¶
- to: smtp://mail.example.com?from=ops@example.com
# body: "Report attached."
# headers:
# Attachments: { report.csv: [bytes] }