email-service
Skill110 starsChanged 9 months agoApache-2.0View on GitHub
Email sending patterns for transactional and marketing emails. Use when implementing email sending, templates, SMTP configuration, or email services like SendGrid, Resend, or Mailgun.
- Reads credentials
In this repository75 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- algorithmic-artSkill
- api-designSkill
- apple-notesSkill
- apple-remindersSkill
- article-writingSkill
- async-pythonSkill
- brand-guidelinesSkill
- camsnapSkill
- canvas-designSkill
- celery-tasksSkill
- claude-apiSkill
- coding-agentSkill
- content-engineSkill
- diffsSkill
- doc-coauthoringSkill
- docker-deploymentSkill
- docxSkill
- e2e-testingSkill
- fastapi-backendSkill
- frontend-designSkill
- frontend-slidesSkill
- gh-issuesSkill
- githubSkill
- git-workflowSkill
- graphql-apiSkill
- healthcheckSkill
- internal-commsSkill
- investor-materialsSkill
- jwt-authenticationSkill
- market-researchSkill
- mcp-builderSkill
- mermaid-diagramsSkill
- microservicesSkill
- mobile-react-nativeSkill
- model-usageSkill
- nextjs-fullstackSkill
- nodejs-expressSkill
- obsidianSkill
- openai-whisperSkill
- oracleSkill
- pdfSkill
- peekabooSkill
- planning-with-filesSkill
- postgres-databaseSkill
- pptxSkill
- prisma-ormSkill
- proseSkill
- pytest-patternsSkill
- react-typescriptSkill
- redis-cachingSkill
- s3-file-storageSkill
- security-reviewSkill
- session-logsSkill
- skill-creatorSkill
- slack-gif-creatorSkill
- sqlalchemy-ormSkill
- state-managementSkill
- strategic-compactSkill
- stripe-paymentsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 223
Use a transactional email service (Resend, SendGrid, Mailgun) — NEVER raw SMTP in production
- Distinctive: line 224
Always queue emails (Celery/background task) — never send synchronously in request handler
- Distinctive: line 225
Verify sender domain with SPF, DKIM, DMARC records (deliverability)
- Very specific: line 226
Never build HTML emails with f-strings with user input (XSS in email clients)
- Distinctive: line 228
Test email rendering with Litmus or Email on Acid before launch
- Distinctive: line 230
Use separate API keys for transactional vs marketing emails
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Email Service Patterns
Setup (Resend — recommended)
# email.py
import resend
resend.api_key = settings.RESEND_API_KEY
async def send_email(
to: str | list[str],
subject: str,
html: str,
from_email: str = "noreply@yourdomain.com",
) -> str:
"""Send transactional email, return message ID."""
params = resend.Emails.SendParams(
from_=from_email,
to=[to] if isinstance(to, str) else to,
subject=subject,
html=html,
)
email = resend.Emails.send(params)
return email["id"]// lib/email.ts
import { Resend } from 'resend'
const resend = new Resend(process.env.RESEND_API_KEY)
export async function sendEmail(params: {
to: string | string[]
subject: string
html: string
from?: string
}) {
const { data, error } = await resend.emails.send({
from: params.from ?? 'noreply@yourdomain.com',
to: Array.isArray(params.to) ? params.to : [params.to],
subject: params.subject,
html: params.html,
})
if (error) throw new Error(error.message)
return data
}Setup (SendGrid)
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
def send_email_sendgrid(to: str, subject: str, html: str):
message = Mail(
from_email="noreply@yourdomain.com",
to_emails=to,
subject=subject,
html_content=html,
)
client = SendGridAPIClient(settings.SENDGRID_API_KEY)
response = client.send(message)
return response.status_codeHTML Email Templates (React Email)
// emails/WelcomeEmail.tsx
import { Html, Head, Body, Container, Text, Button, Hr } from '@react-email/components'
interface WelcomeEmailProps {
username: string
verifyUrl: string
}
export function WelcomeEmail({ username, verifyUrl }: WelcomeEmailProps) {
return (
<Html>
<Head />
<Body style={{ fontFamily: 'Arial, sans-serif', backgroundColor: '#f4f4f4' }}>
<Container style={{ maxWidth: '600px', margin: '0 auto', padding: '20px' }}>
<Text style={{ fontSize: '24px', fontWeight: 'bold', color: '#333' }}>
Welcome, {username}! 👋
</Text>
<Text style={{ color: '#666', lineHeight: '1.6' }}>
Thanks for signing up. Please verify your email address to get started.
</Text>
<Button
href={verifyUrl}
style={{
backgroundColor: '#3b82f6',
color: '#fff',
padding: '12px 24px',
borderRadius: '6px',
textDecoration: 'none',
display: 'inline-block',
}}
>
Verify Email
</Button>
<Hr />
<Text style={{ color: '#999', fontSize: '12px' }}>
If you didn't create an account, you can safely ignore this email.
</Text>
</Container>
</Body>
</Html>
)
}
// Render to HTML for sending
import { render } from '@react-email/render'
const html = render(<WelcomeEmail username="Alice" verifyUrl="https://..." />)Common Email Types
# email_service.py
from .templates import render_template
async def send_welcome_email(user_email: str, username: str, verify_token: str):
verify_url = f"{BASE_URL}/verify?token={verify_token}"
html = render_template("welcome.html", username=username, verify_url=verify_url)
await send_email(user_email, f"Welcome to MyApp, {username}!", html)
async def send_password_reset(email: str, reset_token: str):
reset_url = f"{BASE_URL}/reset-password?token={reset_token}"
html = render_template("password_reset.html", reset_url=reset_url)
await send_email(email, "Reset your password", html)
async def send_invoice(email: str, invoice_data: dict):
html = render_template("invoice.html", **invoice_data)
await send_email(email, f"Invoice #{invoice_data['invoice_number']}", html)
async def send_notification(email: str, title: str, message: str):
html = f"""
<div style="font-family: Arial; padding: 20px;">
<h2>{title}</h2>
<p>{message}</p>
</div>
"""
await send_email(email, title, html)Jinja2 Templates (Python)
from jinja2 import Environment, FileSystemLoader
env = Environment(loader=FileSystemLoader("templates/emails"))
def render_template(template_name: str, **context) -> str:
template = env.get_template(template_name)
return template.render(**context)<!-- templates/emails/welcome.html -->
<!DOCTYPE html>
<html>
<body style="font-family: Arial; background: #f4f4f4; padding: 20px;">
<div style="max-width: 600px; margin: 0 auto; background: white; padding: 30px; border-radius: 8px;">
<h1 style="color: #1a1a1a;">Welcome, {{ username }}! 👋</h1>
<p style="color: #666;">Click below to verify your email:</p>
<a href="{{ verify_url }}"
style="background: #3b82f6; color: white; padding: 12px 24px; border-radius: 6px; text-decoration: none;">
Verify Email
</a>
<p style="color: #999; font-size: 12px; margin-top: 20px;">
This link expires in 24 hours.
</p>
</div>
</body>
</html>Email Queue (Background with Celery)
from celery import Celery
celery = Celery("tasks", broker=settings.REDIS_URL)
@celery.task(bind=True, max_retries=3, default_retry_delay=60)
def send_email_task(self, to: str, subject: str, html: str):
try:
send_email_sync(to, subject, html)
except Exception as exc:
raise self.retry(exc=exc)
# Usage — don't block the request
send_email_task.delay(user.email, "Welcome!", welcome_html)SMTP (nodemailer / standard SMTP)
import nodemailer from 'nodemailer'
const transporter = nodemailer.createTransport({
host: process.env.SMTP_HOST,
port: 587,
secure: false,
auth: {
user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS,
},
})
export async function sendEmail(to: string, subject: string, html: string) {
await transporter.sendMail({
from: '"MyApp" <noreply@myapp.com>',
to,
subject,
html,
})
}Rules
- Use a transactional email service (Resend, SendGrid, Mailgun) — NEVER raw SMTP in production
- Always queue emails (Celery/background task) — never send synchronously in request handler
- Verify sender domain with SPF, DKIM, DMARC records (deliverability)
- Never build HTML emails with
f-stringswith user input (XSS in email clients) - Include unsubscribe link in marketing emails (CAN-SPAM / GDPR)
- Test email rendering with Litmus or Email on Acid before launch
- Rate limit: max 1 email per minute per recipient to avoid spam classification
- Use separate API keys for transactional vs marketing emails
- Log email send attempts (ID, recipient, template, status) in your DB
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

