Files
fn_registry/functions/infra/email_with_attachment.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

45 lines
1.6 KiB
Markdown

---
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, pendiente-usar]
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.