Send an email

To send emails to other SAFE Network users, you need to know their email ID.

First, the app retrieves the encryption key associated with the appendable data that belongs to the recipient. Then, it encrypts the email using that encryption key and saves it as immutable data. Finally, it appends the immutable data that represents the email to the appendable data of the recipient.

Contents

Compose Mail page

The JSON data for the above email would look like this:

Get the appendable data of the recipient

Before fetching the encryption key of the recipient, the app needs to obtain an appendable data handle.

Get a data identifier handle

First, the app fetches a data identifier handle for the appendable data of the recipient.

data_id_handle_actions.js

The name of the appendable data is obtained by hashing the email ID of the recipient:

app_utils.js

Get an appendable data handle

The app fetches an appendable data handle using the data identifier handle previously obtained.

appendable_data_actions.js

Drop the data identifier handle

The app drops the data identifier handle for the appendable data of the recipient.

data_id_handle_actions.js

Get the encryption key of the recipient

After the appendable data handle is successfully obtained, the app fetches an handle for the public encryption key of the recipient. By encrypting your email using that encryption key, only the recipient will be able to read it. This is known as asymmetric encryption.

appendable_data_actions.js

Get a cipher options handle

The app fetches a cipher options handle for asymmetric encryption using the encryption key handle of the recipient.

cipher-opts_actions.js

Drop the encryption key handle

The app drops the encryption key handle of the recipient.

appendable_data_actions.js

Create the email

The app creates an email using the cipher handle that contains the encryption key of the recipient.

Get an immutable data writer handle

First, the app fetches an immutable data writer handle.

immutable_data_actions.js

Write immutable data

The app stores the email as immutable data using the immutable data writer handle.

immutable_data_actions.js

Close the immutable data writer

The app encrypts the data map of the email using the cipher handle that contains the encryption key handle of the recipient. The data map is stored as immutable data on the SAFE Network.

immutable_data_actions.js

Once the write operation is successful, the API returns a data identifier handle for the data map of the email.

Drop the immutable data writer handle

The app drops the immutable data writer handle.

immutable_data_actions.js

Append the email to the appendable data

The app adds the data identifier handle representing your email to the appendable data of the recipient.

appendable_data_actions.js

Drop the appendable data handle

After your email is successfully appended to the appendable data of the recipient, the app drops the appendable data handle.

appendable_data_actions.js

Last updated

Was this helpful?