> For the complete documentation index, see [llms.txt](https://help.claritylims.illumina.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.claritylims.illumina.com/api-and-database/api-docs/application-examples/page-15/email-notifications.md).

# Email Notifications

Stakeholders are interested in the progress of samples as they move through a workflow. E-mail alerts of events can provide them with real-time notifications.

Some possible uses of notifications include the following:

* Completion of a workflow for billing department
* Manager review requests
* Notice of new files added via the Collaborations Lablink Interface
* Updates on samples that are not following a standard path through a workflow

Clarity LIMS provides a simple way of accomplishing this using a combination of the Clarity LIMS API, EPP / automation triggers, and Simple Mail Transfer Protocol (SMTP).

### Solution <a href="#h_27cc8d06-643e-4064-9396-5b7dc897af93" id="h_27cc8d06-643e-4064-9396-5b7dc897af93"></a>

The **send\_email()** method uses the Python **smptlib** module to create a Simple Mail Transfer Protocol (SMPT) object to build and send the email. The attached script does the following:

1. Gathers relevant data from the Clarity LIMS API endpoints.
2. Generates an email body according to a template.
3. Calls the send\_email() function.

### Mail Server Configuration <a href="#h_47d7cbc0-8faa-4daa-b0c5-6551301a7035" id="h_47d7cbc0-8faa-4daa-b0c5-6551301a7035"></a>

Connect to Clarity SMTP with:

* host='localhost', port=25

Because of server restrictions, the script can send emails from only:

* <noreply.clarity@illumina.com>

### Automation Parameters <a href="#h_40755511-3a81-4d23-9bfb-a64d29cdc73d" id="h_40755511-3a81-4d23-9bfb-a64d29cdc73d"></a>

The automation / EPP command is configured to pass the following parameters:

<table data-header-hidden><thead><tr><th width="138"></th><th></th></tr></thead><tbody><tr><td>-u</td><td>The username of the current user (Required)</td></tr><tr><td>-p</td><td>The password of the current user (Required)</td></tr><tr><td>-s</td><td>The URI of the step that launches the script (Required)</td></tr></tbody></table>

Example command line:

{% code overflow="wrap" %}

```
python /opt/gls/clarity/customextensions/emails_from_Clarity.py -u {username} -p {password} -s {stepURI}
```

{% endcode %}

### User Interaction <a href="#h_90dba70a-9784-4fb1-87ea-af8a60e4894d" id="h_90dba70a-9784-4fb1-87ea-af8a60e4894d"></a>

* The script can be executed using a Clarity LIMS automation / EPP command, and trigged by one of the following methods:
  * Manually, via a button on the **Record Details** screen.
  * Automatically, at a step milestone (on entry to or exit from a screen).
* The script can also be triggered outside of a Clarity LIMS workflow, using a time-based job scheduler such as cron.

### Assumptions and Notes <a href="#h_42cecd45-d053-4a9d-bb6f-c148b7a3de46" id="h_42cecd45-d053-4a9d-bb6f-c148b7a3de46"></a>

* You are running a version of Python that is supported by Clarity LIMS, as documented in the *Clarity LIMS Technical Requirements*.
* The example code is provided for illustrative purposes only. It does not contain sufficient exception handling for use 'as is' in a production environment.

### Attachments <a href="#h_d44aacee-22d6-47bb-aebd-ae83d707ddc6" id="h_d44aacee-22d6-47bb-aebd-ae83d707ddc6"></a>

emails\_from\_clarity.py:

{% file src="/files/tU0UXqbXXRmvJCRFSILL" %}

emails\_attachmentPOC.py:

{% file src="/files/74vUk74hFPk3DODwj2CQ" %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.claritylims.illumina.com/api-and-database/api-docs/application-examples/page-15/email-notifications.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
