GithubHelp home page GithubHelp logo

elasticemail / elasticemail.webapiclient-js Goto Github PK

View Code? Open in Web Editor NEW
16.0 4.0 9.0 3.76 MB

Deprecated library. Easily send emails with Elastic Email using Web API JS Client https://elasticemail.com/

License: MIT License

JavaScript 100.00%

elasticemail.webapiclient-js's Introduction

Elasticemail-webapiclient (LEGACY)

New version of API - https://github.com/ElasticEmail/elasticemail-js

N|ElasticEmail

Prerequisites

Getting account info in Node

npm install elasticemail-webapiclient
const eeClient = require('elasticemail-webapiclient').client;

const options = {
    apiKey: 'YourApiKey',
    apiUri: 'https://api.elasticemail.com/',
    apiVersion: 'v2'
}

const EE = new eeClient(options);

// Load account data
EE.Account.Load().then(function(resp) {
    console.log(resp);
});

const emailParams = {
    "subject": 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
    "to": '[email protected]',
    "from": '[email protected]',
    "replyTo": '[email protected]',
    "body": 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' +
    ' Curabitur in lectus id ipsum laoreet dignissim in ut odio. Duis volutpat arcu dolor, eu cursus mi vestibulum ut.' +
    ' Etiam eu ipsum orci. Vestibulum aliquam eros in massa dapibus malesuada. Proin sit amet blandit nulla, eu porttitor neque.' +
    ' Duis consequat erat est, sit amet condimentum turpis sagittis sit amet. Nam fringilla, tellus ac euismod elementum,' +
    ' ipsum ante consequat nisi, ut lobortis arcu sapien vel ex. Mauris sit amet magna a ipsum porttitor hendrerit.' +
    ' Nam elementum iaculis tellus, nec euismod ante. Suspendisse nec lobortis magna, at placerat augue.' +
    ' Quisque luctus scelerisque metus, ut facilisis mi consectetur vel. Ut augue diam, ornare dictum tincidunt a,' +
    ' volutpat nec arcu. Mauris iaculis bibendum pulvinar. Quisque vestibulum, magna quis aliquam tincidunt,' +
    ' leo eros luctus nibh, eu dictum nisl velit id mauris.',
    "fromName": 'John Doe',
    "bodyType": 'Plain'
};

// Send email
EE.Email.Send(emailParams)
.catch((err) => {
    throw new Error(err);
});

API

API documentation you can find on Elastic Email website.

About

ElasticEmail.WebApiClient is guided and supported by the ElasticEmail Dev Team.

ElasticEmail.WebApiClient is maintained and funded by Elastic Email Inc. The names and logos for ElasticEmail.WebApiClient are trademarks of Elastic Email Inc.

elasticemail.webapiclient-js's People

Contributors

dependabot[bot] avatar eeppodolak avatar glokam avatar ppodolak avatar rimiti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

elasticemail.webapiclient-js's Issues

not able use any other function other than send email

by using above library i am only able to use send email functions remaining functions are not able to access. kindly provide any way so i can integrate account apis as well. index.ts file only having Email class.

"Access Denied" comes up when requested through the issued api key.

initialized the client with the newly issued hot Apikey.

import ee from 'elasticemail-webapiclient'

const onlyViewApikey =
  'B0A437740E95AE435073F101F72D63CC240803CA4C3DA91B8A5B5396236FEB2D4A30EB05543BF8018CD5CBDD52391FEA'
const options = {
  apiKey: onlyViewApikey,
  apiUri: 'https://api.elasticemail.com/',
  apiVersion: 'v2'
}

const EE = new ee(options)

// Load account data
EE.Account.Load()
  .then(function(resp) {
    console.log(resp.data)
  })
  .catch(error => {
    console.log(error)
  })

The response result I received is "access Denied".

why.. help me thank you

below is the response I received.

...
    [Symbol(kNeedDrain)]: false,
    [Symbol(isCorked)]: false,
    [Symbol(kOutHeaders)]: [Object: null prototype] {
      accept: [Array],
      'content-type': [Array],
      'user-agent': [Array],
      host: [Array]
    }
  },
  data: { success: false, error: 'Access Denied.' }
}
Access Denied.

Updating to this version broke my server (webapiclient v 2.0.12, node v8)

This call that was working perfectly fine, now fails.

const EEOptions = {
  apiKey: 'BA05CB368C38B35F6F92D6573EA12D5343F465D18656DD7C80C4F27A708D1DF4BDAF7974F20DCDA80F830C3D8BE86CEA',
  apiUri: 'https://api.elasticemail.com/',
  apiVersion: 'v2'
};

//************** */
// ElasticEmail Account APIs
//************** */
export async function eeAccountAddSubaccount(email: string) {
  const data = {
    email: email,
    password: 'placeHolderPassw0rd',
    confirmPassword: 'placeHolderPassw0rd'
  };

  const eeClient = require('elasticemail-webapiclient').client;

  const EE = new eeClient(EEOptions);

  // ***** -> the following fails with 'undefined'
  return await EE.Account.AddSubAccount(data).catch((err: any) => console.error('error from elasticEmail: ', err));
}

The call fails with an undefined error. For the same reason, EE.Account.GetSubAccountApiKey fails as well, which pretty much prevents me from doing any operation.

This is a blocking isue.

TypeError: source.on is not a function

hey I did the same configuration as mentioned here to send emails. but I am getting below error while sending emails

email sendig error : TypeError: source.on is not a function
at Function.DelayedStream.create (/home/sahil/Documents/node_modules/delayed-stream/lib/delayed_stream.js:33:10)
at FormData.CombinedStream.append (/home/sahil/Documents/node_modules/combined-stream/lib/combined_stream.js:45:37)

I am not able to understand this error.

Verify DMARC is missing

Hello,

I noticed that the email/verifydmarc endpoint is missing from the api client.
Can you please add this?

Thank you

self._form.on is not a function

Hi there,

I got this error

"self._form.on is not a function"

when I tested it on my project.
please give me help.

Thank you.

Not working with typescript in react

i did same configurations as mentioned here but it is giving error as undefined whenever we send emails. but whenever I use same code in .js code is working fine.

how we can run this code in typescript?

Are there any Types (d.ts)?

Hi,
My startup is considering to use your service.
We are using typescript and it would be amazing if you had types.

You do have a lot of comment docs, but its still confusing.
For example:
On Logs.Load(), the status param doc is:

  • @param {Object} data.statuses - List of comma separated message statuses: 0 for all, 1 for ReadyToSend, 2 for InProgress, 4 for Bounced, 5 for Sent, 6 for Opened, 7 for Clicked, 8 for Unsubscribed, 9 for Abuse Report.

So what is it? It says its an {Object}, and a list, and what does a list mean? A javascript array or a string of comma seperated numbers?

Thanks,
Itay

The npm package is 1.4.0 but this repo is 1.3.0

Hi

the version that is published in npm seems to not have been pushed to this repo ...

also the line "var export = {}" creates an incompatibility with ES6 since export is a reserved word, so this library doesn't work with node 8.x for example

Am I doing this right? Emails not getting sent via Node.js server...

I'm using this library, getting success messages from the server, but alas, no emails seem to be getting thru.
--I'm using https://www.npmjs.com/package/elasticemail-webapiclient

const eeClient = require('elasticemail-webapiclient').client;
const { ELASTICEMAIL_API_KEY } = require("../../config");

const options = {
    apiKey: ELASTICEMAIL_API_KEY,
    apiUri: 'https://api.elasticemail.com/',
    apiVersion: 'v2'
}

const SendAnEmail = (msgContent) => {
    const EE = new eeClient(options);
    // Load account data
    EE.Account.Load().then(function (resp) {
        console.log(resp);
    });
    // Send email
    EE.Email.Send(msgContent)
        .catch((err) => {
            console.log("Oops, Error from ElasticEmail Server while sending email: ", err)
            throw new Error(err);
        });
}
module.exports = SendAnEmail;

function called with message, directly copied from the readme file on this repo. Only thing I changed was I added my own email in the to: block.

Function called, I see a message in the console log on the server (running on localhost):

{success: true, data: {…}}
src/helpers/sendAnEmail.js:40
data:{taxcode: '', publicaccountid: 'baxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', apikey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx', issub: false, isuser: false}
success:true
__proto__:Object

Yet, I see no email in my inbox, no email in my spam folder. Console at ElasticEmail shows absolute no account activity at all. Am I doing this correctly?

How to create a non-scheduled campaign from the API

Hello,
First, thank you for your service that I use to send a newsletter about JavaScript trends: https://weekly.bestofjs.org/.
I try to create a campaign using the campaign/add end point from the API.

A parameter named campaign is expected. When I use the following value:

{
  name: 'My campaign',
  targets: [l123],
  CampaignTemplates: [
    {
      TemplateID: '5213',
      TemplateSubject: 'My subject',
      TemplateFromEmail: '[email protected]',
      TemplateReplyEmail: '[email protected]',
      TemplateReplyName: 'Best of JavaScript'
    }
  ],
  TriggerType: 1 // 1 means "SendNow"
}

...I get the following error:

Trigger count and trigger frequency can only be set for scheduled campaigns

But I don't pass any "trigger" parameter and I don't want a scheduled newsletter, I want to send it manually later.

Am I missing something? How can I unset the "trigger" parameters?
Thank you very much for your help!

Not documented how to attach files (File.Upload)

Hello! I'm trying to use the File.Upload API, but it is not well documented. For example, the "file" argument says in the JSDoc that is an Object, but not specifies what type of object.

Can you put an example on how to attach files or add the correct documentation to the JSDoc?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.