From 99bdf2fb14c8bde0c61f687ef4a0421a42282968 Mon Sep 17 00:00:00 2001 From: Zack Schuster Date: Tue, 1 Dec 2020 15:20:43 -0800 Subject: [PATCH] chore: add async/await example to readme --- README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/README.md b/README.md index f4b8b73..d796e0a 100644 --- a/README.md +++ b/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 ', + to: 'someone , another ', + cc: 'else ', + subject: 'testing emailjs', + }); + console.log(message); +} catch (err) { + console.error(err); +} +``` + ## EXAMPLE USAGE - html emails and attachments ```js