Skip to main content
Resend Docs
current

Search documentation

Type to search this documentation.

On this pageOverview

Send emails with Deno Deploy

Learn how to send your first email using Deno Deploy.

Before you start, you'll need:

  1. Create a Deno Deploy project

    Go to dash.deno.com/projects and create a new playground project.

    Deno Deploy - New Project

  2. Edit the handler function

    Paste the following code into the browser editor:

    main.ts
    import { Resend } from 'npm:resend';
    
    const resend = new Resend('re_123456789');
    
    Deno.serve(async () => {
      try {
        const response = await resend.emails.send({
          from: 'Acme <onboarding@resend.dev>',
          to: ['delivered@resend.dev'],
          subject: 'Hello World',
          html: '<strong>It works!</strong>',
        });
    
        return new Response(JSON.stringify(response), {
          status: response.error ? 500 : 200,
          headers: {
            'Content-Type': 'application/json',
          },
        });
      } catch (error) {
        console.error(error);
        return new Response(null, {
          status: 500,
        });
      }
    });
  3. Deploy and send email

    Click on Save & Deploy at the top of the screen.

    Deno Deploy - Playground

Deno Deploy Example

See the full source code.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu