chore: add async/await example to readme

This commit is contained in:
Zack Schuster 2020-12-01 15:20:43 -08:00
parent 3403819397
commit 99bdf2fb14
1 changed files with 27 additions and 0 deletions

View File

@ -50,6 +50,33 @@ client.send(
);
```
## EXAMPLE USAGE - using async/await
```js
// assuming top-level await for brevity
import { SMTPClient } from 'emailjs';
const client = new SMTPClient({
user: 'user',
password: 'password',
host: 'smtp.your-email.com',
ssl: true,
});
try {
const message = await client.sendAsync({
text: 'i hope this works',
from: 'you <username@your-email.com>',
to: 'someone <someone@your-email.com>, another <another@your-email.com>',
cc: 'else <else@your-email.com>',
subject: 'testing emailjs',
});
console.log(message);
} catch (err) {
console.error(err);
}
```
## EXAMPLE USAGE - html emails and attachments
```js