Email Notifications
CodeMash Email Notifications service allows you to send emails to your users and emails. All email queuing and management is accessible through the dashboard. You can also send emails through API.
To start using Email service and it's API methods, you firstly need to enable email service in your CodeMash dashboard.
Features included in email service:
  1. 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.
.NET
Node
PHP
1
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
2
var apiKey = "{YOUR_SECRET_KEY}";
3
4
var client = new CodeMashClient(apiKey, projectId);
5
var emailService = new CodeMashEmailService(client);
Copied!
1
Copied!
1
use Codemash\CodemashClient;
2
use Codemash\CodemashEmail;
3
4
class CodemashService
5
{
6
protected CodemashEmail $codemashEmail;
7
8
public function __construct()
9
{
10
$secretKey = '{YOUR_SECRET_KEY}';
11
$projectId = '{YOUR_PROJECT_ID}';
12
13
$client = new CodemashClient($secretKey, $projectId);
14
$this->codemashEmail = new CodemashEmail($client);
15
}
16
17
}
Copied!

Example

The following are examples of email notifications SDK using different languages and frameworks.
.NET
Node
PHP
1
using System;
2
using CodeMash.Client;
3
using CodeMash.Notifications.Email.Services;
4
using Isidos.CodeMash.ServiceContracts;
5
6
namespace ConsoleApplication
7
{
8
class Program
9
{
10
static void Main(string[] args)
11
{
12
// 1. Get your Project ID and Secret Key
13
var projectId = Guid.Parse("{YOUR_PROJECT_ID}");
14
var apiKey = "{YOUR_SECRET_KEY}";
15
16
// 2. Create a general client for API calls
17
var client = new CodeMashClient(apiKey, projectId);
18
19
// 3. Create a service object
20
var emailService = new CodeMashEmailService(client);
21
22
// 4. Call an API method
23
var response = emailService.SendEmail(new SendEmailRequest
24
{
25
TemplateId = Guid.Parse("{TEMPLATE_ID}"),
26
Emails = new [] { "[email protected]" }
27
});
28
}
29
}
30
}
Copied!
1
Copied!
1
use Codemash\CodemashClient;
2
use Codemash\CodemashEmail;
3
4
class CodemashService
5
{
6
protected CodemashEmail $codemashEmail;
7
8
public function __construct()
9
{
10
$secretKey = '{YOUR_SECRET_KEY}';
11
$projectId = '{YOUR_PROJECT_ID}';
12
13
$client = new CodemashClient($secretKey, $projectId);
14
$this->codemashEmail = new CodemashEmail($client);
15
}
16
17
public function sendEmail()
18
{
19
$responseData = $this->codemashEmail->send([
20
'templateId' => '{TEMPLATE_ID}',
21
'emails' => [
25
],
26
]);
27
}
28
}
Copied!

Working with Email Service

The following links explore the usage of email service:
Last modified 1yr ago