53deb8e9a8
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>
52 lines
1.5 KiB
Markdown
52 lines
1.5 KiB
Markdown
---
|
|
name: email_build_html
|
|
kind: function
|
|
lang: go
|
|
domain: infra
|
|
version: "1.0.0"
|
|
purity: pure
|
|
signature: "func EmailBuildHTML(from string, to []string, subject, bodyHTML string) EmailMessage"
|
|
description: "Construye un EmailMessage con cuerpo HTML. Retorna una nueva estructura sin CC, BCC, adjuntos ni headers custom."
|
|
tags: [email, smtp, html, builder]
|
|
uses_functions: []
|
|
uses_types: [EmailMessage_go_infra]
|
|
returns: [EmailMessage_go_infra]
|
|
returns_optional: false
|
|
error_type: ""
|
|
imports: []
|
|
params:
|
|
- name: from
|
|
desc: "direccion del remitente (ej: 'Alice <alice@example.com>')"
|
|
- name: to
|
|
desc: "lista de direcciones de destinatarios principales"
|
|
- name: subject
|
|
desc: "asunto del correo"
|
|
- name: bodyHTML
|
|
desc: "contenido HTML del cuerpo del mensaje"
|
|
output: "EmailMessage listo para enviar con cuerpo HTML"
|
|
tested: true
|
|
tests:
|
|
- "construye mensaje html con campos basicos"
|
|
- "copia el slice to para evitar aliasing"
|
|
- "campos no usados quedan vacios"
|
|
test_file_path: "functions/infra/email_build_test.go"
|
|
file_path: "functions/infra/email_build_html.go"
|
|
---
|
|
|
|
## Ejemplo
|
|
|
|
```go
|
|
msg := EmailBuildHTML(
|
|
"alice@example.com",
|
|
[]string{"bob@example.com", "carol@example.com"},
|
|
"Reporte mensual",
|
|
"<h1>Hola</h1><p>Ver adjunto.</p>",
|
|
)
|
|
// msg.BodyHTML = "<h1>Hola</h1><p>Ver adjunto.</p>"
|
|
// msg.BodyText = ""
|
|
```
|
|
|
|
## Notas
|
|
|
|
Funcion pura. Copia el slice `to` para evitar aliasing con el caller. Para anadir adjuntos usar `EmailWithAttachment`. Para texto plano usar `EmailBuildText`.
|