Send and receive emails in minutes.
Send an email with one line of Python
anvil.email.send(to="email@example.com",subject="Welcome",text="Hello from Anvil!")
The easiest way to send and receieve emails
Anvil lets you send and receive emails with just a few lines of Python.
It’s free to use – give it a try:
Receive emails with Python
To receive emails with Python, all you need to do is decorate a function as
@anvil.email.handle_message def handle_incoming_email(msg): # Reply to the email msg.reply(text="Thank you for your message.")
Learn more about receiving emails with Python by building a disposable email service:
Store emails and attachments in your database
It’s simple to save incoming emails and attachments in your database.
This function handles incoming emails, sends an automatic reply, and stores messages and attachments in Anvil’s built-in database:
@anvil.email.handle_message def receive_emails(): # auto-respond to the incoming email msg.reply(text="Thank you for your message.") # Store the email in your database msg_row = app_tables.received_messages.add_row( from_addr=msg.envelope.from_address, to=msg.envelope.recipient, text=msg.text, html=msg.html ) # Store the attachment(s) in your database for a in msg.attachments: app_tables.attachments.add_row( message=msg_row, attachment=a )
See an example that lets you upload a photo and emails it to someone:
Try it for yourself
Anvil is free to use – give it a try:
You can also read more about Anvil in the reference docs.
Here are some example apps to get you started:
Get Started with Anvil
Nothing but Python required!