feat: tipos y funciones email SMTP en Go (infra)
Tipos: EmailAttachment, EmailMessage, SMTPConfig. Puras: email_build_html, email_build_text, email_with_attachment, email_template_render. Impuras: smtp_connect (TLS/STARTTLS/plain), smtp_send (MIME multipart con adjuntos). Solo stdlib: net/smtp, crypto/tls, text/template, mime/multipart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
---
|
||||
name: email_with_attachment
|
||||
kind: function
|
||||
lang: go
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "func EmailWithAttachment(msg EmailMessage, att EmailAttachment) EmailMessage"
|
||||
description: "Retorna una copia del EmailMessage con el adjunto añadido al final. No muta el mensaje original."
|
||||
tags: [email, smtp, attachment, immutable, builder]
|
||||
uses_functions: []
|
||||
uses_types: [EmailMessage_go_infra, EmailAttachment_go_infra]
|
||||
returns: [EmailMessage_go_infra]
|
||||
returns_optional: false
|
||||
error_type: ""
|
||||
imports: []
|
||||
params:
|
||||
- name: msg
|
||||
desc: "mensaje email existente del que se obtiene la copia base"
|
||||
- name: att
|
||||
desc: "adjunto a agregar: nombre, MIME type y datos binarios"
|
||||
output: "nuevo EmailMessage con todos los campos del original mas el adjunto añadido"
|
||||
tested: true
|
||||
tests:
|
||||
- "agrega adjunto sin mutar el original"
|
||||
- "multiples adjuntos se acumulan"
|
||||
- "copia todos los campos del mensaje"
|
||||
test_file_path: "functions/infra/email_build_test.go"
|
||||
file_path: "functions/infra/email_with_attachment.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
msg := EmailBuildHTML("alice@example.com", []string{"bob@example.com"}, "Informe", "<p>Ver adjunto</p>")
|
||||
att := EmailAttachment{Filename: "report.pdf", ContentType: "application/pdf", Data: pdfBytes}
|
||||
msg2 := EmailWithAttachment(msg, att)
|
||||
// len(msg.Attachments) == 0 (original no mutado)
|
||||
// len(msg2.Attachments) == 1
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Funcion pura. Implementa el patron immutable builder — cada llamada retorna un nuevo `EmailMessage` con copia profunda de todos los slices y mapas. Se puede encadenar varias veces para agregar multiples adjuntos.
|
||||
Reference in New Issue
Block a user