Skip to content

Email

Email vals get their own email address that you can send email to. When Val Town receives that email, it triggers the val with the email as its first argument.

Type Signature

Email vals receive an argument called Email that represents the email that was sent to the val. Here’s an example of an email val:

Example
export async function emailValHandler(email: Email) {
console.log("Email received!", email.from, email.subject, email.text);
for (const file of email.attachments) {
console.log(`Filename: ${file.name}`)
console.log(`Content Type: ${file.type}`)
console.log(`Content: ${await file.text()}`)
};
}

The Email type has this shape:

interface Email {
from: string;
to: string[];
subject: string | undefined;
text: string | undefined;
html: string | undefined;
attachments: File[];
}

Example

This val forwards any email it receives to me. Try it out by sending an email to stevekrouse.forwarder@valtown.email.

Limitations