Send & receive email
All Membrane programs are capable of sending and receiving emails. Similar to
HTTP endpoints, all you need to do is export an email
function from the root of your program and use the program’s unique email
address.
To get a program’s email address, click “Copy Email Address” above the email
function signature. Or right-click the program name in the Navigator and select
“Copy Email Address”.
Basic Example
This program receives an email and uses the email
program to forward the email
to the currently signed in user’s inbox. In order to run this program make sure
you
add email
as a dependency.
Attachments
Email handlers support receiving attachments via the attachments
property on
the object passed to the function. attachments
is an array of attachment
objects with a downloadUrl
and name
. Attachments are automatically deleted
from our backend after 30 minutes of being received. Please reach out to
contact@membrane.io if you need more time.
You can access attachment data by fetch
’ing from the downloadUrl
and parsing
like so:
const { name, downloadUrl } = attachments[0]const data = await fetch(downloadUrl)const buffer = await data.bytes() // OR: await data.arrayBuffer()