[BUG] Sendgrid API sending duplicate emails to same recipient email address

Hello everyone,

Running into a strange issue I’m wondering if anyone else is experiencing. I am currently using the SendGrid NodeJS package method to send occasional emails out.

I call on the send email function using the following line of code:
sendEmail(recipient, subject, sender, body);

Despite calling this function once, I’m seeing two duplicate (exactly identical) emails that show up in the recipient email inbox.

Any idea what may be causing this? Any help greatly appreciated.

Yisrael (Wix Admin) has already posted a tutorial about this.
https://www.wix.com/corvid/forum/wix-tips-and-updates/example-send-email-with-the-sendgrid-npm-interface

Hope this helps somehow, unless of course you have already seen it and used it and then it was a pointless reply!

I have only used SendGrid emails through this tutorial and as everything worked fine, I haven’t bothered to change it and use the node package instead.
https://support.wix.com/en/article/corvid-tutorial-sending-an-email-on-form-submission

Finally, as that line…

sendEmail(recipient, subject, sender, body);

… should be in your backend jsw file, then it will either be an error with your code or an error/bug within SendGrid’s own node.js.

Although one positive point to look at, at least you are getting double emails sometimes, it could be worse and you get no emails!

Also, before I forget, when I setup my own SendGrid account I made sure that I setup the authentication side too, it might be worth it for you too if you haven’t done it already.
How to set up domain authentication | Twilio

Thank you for your response. Very helpful.

After some investigation, I think I might have found the cause. At first, I wanted to save time and duplicated another page that has the sendEmail code within. I customized the duplicated page to my needs on the new page and figured it would work similar. I kept getting the duplicate emails in this case.

So what I did then was create a brand new page, and redeveloped the page elements and code from scratch. This time, only one email is sent (vs. the duplicate emails).

I’m guessing something in Wix that didn’t clean out residual background code when you duplicate pages.

I sent this on to QA for evaluation.

As I relate in this post , QA reports that this is in fact a bug and a ticket has been opened with development.