• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
drew_kuhn

drew_kuhn

inventiveVioletDinosaur

Public
Like
inventiveVioletDinosaur
Home
Code
2
README.md
main.tsx
Environment variables
Branches
1
Pull requests
Remixes
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
11/18/2024
Viewing readonly version of main branch: v5
View latest version
README.md

With our data designed, let’s build the email! Val Town makes this super easy since it provides a robust email package. The package exports a function by the same name (email) which consumes an object. When called with properly formatted parameters, an email will be sent to the address associated with your Val Town account.

“Good” emails need some kind of hook to draw the reader’s attention. What better hook than our joke’s setup? Add an email() function call to your Val which sends an email with the setup as its subject and the punchline as its body text.

import { email } from "https://esm.town/v/std/email?v=9";

// Fetches a random joke. function fetchRandomJoke() { const SAMPLE_JOKE = { "setup": "What do you call a group of disorganized cats?", "punchline": "A cat-tastrophe.", }; return SAMPLE_JOKE; }

const randomJoke = fetchRandomJoke(); const setup = randomJoke.setup; const punchline = randomJoke.punchline;

// Sends an email with the joke. export const emailRandomJoke = email({ text: punchline, subject: setup, }); Notice that this data is being passed in as key-value pairs since it is inside of an object. There is only one parameter (that object) passed into the function.

Save and evaluate your val by clicking the “Run” button at the top right.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
© 2026 Val Town, Inc.