Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

Sending Email

Are you new here?

Anvil is a tool for building full-stack web apps with nothing but Python and a drag-and-drop designer. Learn more on our website, or sign up and try it yourself -- it's free!

Anvil apps can send email with a single command. They can also receive email.

To send email, enable the Email service and simply run anvil.email.send from the client or server.

anvil.email.send(
  to="customer@example.com",
  from_address="support",
  from_name="MyApp Support",
  subject="Welcome to MyApp",
  html="<h1>Welcome!</h1>"
)

To receive email, decorate a server function as a message handler using @anvil.email.handle_message. Its first argument is then an object representing emails sent to the app.

You can reply to the incoming message using reply. Store your message in a Data Table and you can display it on a Form to create a quick email client, such as this example app).

@anvil.email.handle_message
def handle_incoming_emails(msg):

  msg.reply(text="Thank you for your message.")

  msg_row = app_tables.received_messages.add_row(
              from_addr=msg.envelope.from_address, 
              to=msg.envelope.recipient,
              text=msg.text, 
              html=msg.html
            )
  for a in msg.attachments:
    app_tables.attachments.add_row(
      message=msg_row, 
      attachment=a
    )