merge: issue/0012-email-smtp — Email SMTP functions

This commit is contained in:
2026-04-13 02:05:03 +02:00
27 changed files with 2068 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
---
name: EmailAttachment
lang: go
domain: infra
version: "1.0.0"
algebraic: product
definition: |
type EmailAttachment struct {
Filename string
ContentType string
Data []byte
}
description: "Archivo adjunto a un email. Contiene nombre, MIME type y datos binarios."
tags: [email, smtp, attachment, mime]
uses_types: []
file_path: "functions/infra/email_types.go"
---
## Ejemplo
```go
att := EmailAttachment{
Filename: "report.pdf",
ContentType: "application/pdf",
Data: pdfBytes,
}
```
## Notas
Tipo producto — todos los campos obligatorios. `Data` es el contenido binario crudo; se codifica en base64 al serializar en MIME. Usado por `EmailMessage.Attachments`.
+33
View File
@@ -0,0 +1,33 @@
---
name: EmailMessage
lang: go
domain: infra
version: "1.0.0"
algebraic: product
definition: |
type EmailMessage struct {
From string
To []string
CC []string
BCC []string
Subject string
BodyHTML string
BodyText string
Attachments []EmailAttachment
Headers map[string]string
}
description: "Mensaje de email listo para enviar. Inmutable — construir con EmailBuildHTML, EmailBuildText o EmailWithAttachment."
tags: [email, smtp, message, mime]
uses_types: [EmailAttachment_go_infra]
file_path: "functions/infra/email_types.go"
---
## Ejemplo
```go
msg := EmailBuildHTML("alice@example.com", []string{"bob@example.com"}, "Hola", "<b>Hola Bob</b>")
```
## Notas
Tipo producto. `BodyHTML` y `BodyText` son opcionales pero al menos uno debe estar presente para que el mensaje sea valido. `Attachments` puede ser nil. `Headers` permite agregar cabeceras MIME custom como `X-Mailer`.
+35
View File
@@ -0,0 +1,35 @@
---
name: SMTPConfig
lang: go
domain: infra
version: "1.0.0"
algebraic: product
definition: |
type SMTPConfig struct {
Host string
Port int
Username string
Password string
TLSMode string
}
description: "Parametros de conexion a un servidor SMTP. TLSMode controla el cifrado: 'tls' (port 465), 'starttls' (port 587) o '' sin cifrado (port 25)."
tags: [email, smtp, config, tls]
uses_types: []
file_path: "functions/infra/email_types.go"
---
## Ejemplo
```go
cfg := SMTPConfig{
Host: "smtp.gmail.com",
Port: 587,
Username: "user@gmail.com",
Password: "app-password",
TLSMode: "starttls",
}
```
## Notas
Tipo producto. `TLSMode` debe ser `"tls"`, `"starttls"` o `""`. Por convencion: port 465 usa TLS directo, 587 usa STARTTLS, 25 sin cifrado. Para Gmail y proveedores modernos usar `"starttls"` en port 587 o `"tls"` en 465.