ElasticEmail / ElasticEmail.WebApiClient-js

Deprecated library. Easily send emails with Elastic Email using Web API JS Client https://elasticemail.com/
MIT License
15 stars 9 forks source link

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

Open zipzit opened 4 years ago

zipzit commented 4 years ago

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?

zipzit commented 4 years ago

Next step, lets verify basic email function, via postman API call, ref: this site.

First attempt using a random from email address = fail. After changing the 'fromaddress to the email address registered with ElasticEmail.com (The problem of course, is that we're in development stage, using a local host server. No domain name even pulled yet, etc...) After changing thefrom` email address, Response =

{
    "success": true,
    "data": {
        "transactionid": "cdxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "messageid": "Jwwsxxxxxxxxxxxxxxxxxxxxxxxxxx"
    }
}

So, eventually the emails generated by a post request sent thru Postman work just fine. But its a total fail when using this node.js plugin.

The real problem here is a call to this plugin generates a Success message, even though the submit fails. Errors are not being propagated back to the server correctly.