Skip to content

Commit

Permalink
chore: example payload (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lebleu authored Feb 21, 2024
1 parent 71fa1e3 commit 11d40fe
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 16 deletions.
49 changes: 34 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,9 @@ Define a minimalist configuration in *.cliamrc.json* newly created:
```json
{
"sandbox": true,
"variables": {
"domain": "https://www.my-website.com",
"addresses": {
"from": {
"name": "John Doe",
"email": "info@john.doe.com"
},
"replyTo": {
"name": "John Doe",
"email": "info@john.doe.com"
}
}
},
"transporters": [
{
"id": "unique-key-for-my-transporter",
"id": "unique-transporter-key",
"mode": "smtp",
"auth": {
"username": "USERNAME",
Expand All @@ -83,6 +70,19 @@ Define a minimalist configuration in *.cliamrc.json* newly created:
"port": 587,
"secure": false
}
},
{
"id": "other-unique-transporter-key",
"mode": "api",
"provider": "sendgrid",
"auth": {
"apiKey": "APIKEY",
},
"options": {
"templates": {
"user.welcome": "d-321bb40f548e4db8a628b4d6464ebacc"
}
}
}
]
}
Expand All @@ -97,7 +97,24 @@ import { Cliam } from 'cliam';

// Do some stuffs ...

Cliam.mail('user.confirm', payload)
const payload = {
meta: {
from: { email: 'john.doe@hotmail.com' },
to: [
{ email: 'john.allan.poe@hotmail.com' }
],
replyTo: { email: 'john.doe@hotmail.com' },
subject: 'Welcome John'
}
content: [
{
type: 'text/html',
value: '<h1>Hello Yoda</h1><p>I use Cliam to send my emails !</p>'
}
]
};

Cliam.mail('user.welcome', payload)
.then(res => {
console.log('Email has been delivered: ', res);
})
Expand All @@ -106,6 +123,8 @@ Cliam.mail('user.confirm', payload)
});
```

By default, Cliam will use the first transporter found in the cliamrc file, except if you precise wich transporterId you want to use on the fly.

See [request payload](https://github.com/steve-lebleu/cliam/wiki/Inputs) wiki section for more information about availables options and configurations.

<h2 id="beneficiary-use-cases">> Beneficiary use cases</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/services/mailer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Mailer {
}

/**
* @description Get the origin domain to use in the setup of the current mailer instance. This is used by some web API providers.
* @description Get the origin domain to use in the setup of the current mailer instance. This is used by some web API providers such mailgun.
*/
private getOrigin(): string {
return Container.configuration.variables.domain;
Expand Down

0 comments on commit 11d40fe

Please sign in to comment.