mirror of https://github.com/eleith/emailjs.git
chore: add async/await example to readme
This commit is contained in:
parent
3403819397
commit
99bdf2fb14
27
README.md
27
README.md
|
@ -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
|
## EXAMPLE USAGE - html emails and attachments
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
Loading…
Reference in New Issue