# Email

## Transactional Emails

Transactional emails are messages sent to customers or users responding to a specific action or event. These emails are triggered automatically based on a user's interactions with an online service or application, and they typically contain information that is relevant to the user's experience with the service. Some examples of transactional emails include confirmation emails, receipts, account updates, password reset instructions, and shipping notifications. These emails are often considered critical for maintaining good customer relationships and providing a high-quality user experience, as they provide essential information and keep users informed about the status of their transactions.

CodeMash **Email Notifications** service is accessible through the dashboard. You can also send emails through API or using CodeMash CLI.

To start using the Email service and its API methods, you first need to enable the email service in your CodeMash dashboard.

Features included in email service:

1. Emails - sending emails to your users.

## Using SDK

If you decide to use one of our provided SDK, the following code shows how to initialize email service.

{% tabs %}
{% tab title=".NET" %}

```csharp
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
var apiKey = "{YOUR_SECRET_KEY}";

var client = new CodeMashClient(apiKey, projectId);
var emailService = new CodeMashEmailService(client);
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashEmail;

class CodemashService
{
    protected CodemashEmail $codemashEmail;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashEmail = new CodemashEmail($client);
    }

}
```

{% endtab %}
{% endtabs %}

## Example

The following are examples of email notifications SDK using different languages and frameworks.

{% tabs %}
{% tab title=".NET" %}

```csharp
using System;
using CodeMash.Client;
using CodeMash.Notifications.Email.Services;
using Isidos.CodeMash.ServiceContracts;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            // 1. Get your Project ID and Secret Key
            var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
            var apiKey = "{YOUR_SECRET_KEY}";

            // 2. Create a general client for API calls
            var client = new CodeMashClient(apiKey, projectId);
            
            // 3. Create a service object
            var emailService = new CodeMashEmailService(client);

            // 4. Call an API method
            var response = emailService.SendEmail(new SendEmailRequest
            {
                TemplateId = Guid.Parse("{TEMPLATE_ID}"),
                Emails = new [] { "test@email.com" }
            });
        }
    }
}
```

{% endtab %}

{% tab title="Node" %}

```
```

{% endtab %}

{% tab title="PHP" %}

```php
use Codemash\CodemashClient;
use Codemash\CodemashEmail;

class CodemashService
{
    protected CodemashEmail $codemashEmail;

    public function __construct()
    {
        $secretKey = '{YOUR_SECRET_KEY}';
        $projectId = '{YOUR_PROJECT_ID}';

        $client = new CodemashClient($secretKey, $projectId);
        $this->codemashEmail = new CodemashEmail($client);
    }

    public function sendEmail()
    {
        $responseData = $this->codemashEmail->send([
            'templateId' => '{TEMPLATE_ID}',
            'emails' => [
                'test1@example.com',
                'test2@example.com',
                'test3@example.com',
            ],
        ]);
    }
}
```

{% endtab %}
{% endtabs %}

## Working with Email Service

The following links explore the usage of email service:

{% content-ref url="/pages/-LwUEOAWuB-CnCm8Ssv1" %}
[Emails](/api/notifications/emails.md)
{% endcontent-ref %}


---

# Agent Instructions: 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:

```
GET https://docs.codemash.io/dashboard/notifications/email.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
