Sending emails through code

I’ve set up an account with a third party email provider and adapted the code as per Wix examples. The code works well in that it returns OK from the ‘fetch’, but no email is received on the other end. Any ideas? Here is the code:

BACK END (sendEmail.jsw):
import {fetch}from ‘wix-fetch’;
export function sendEmail (address, subject, body) {
return fetch(“https://api.sendinblue.com/v2.0?APIKey=h8MwjJKLmfsagh5640YPdfN4yg”, {
method: ‘post’,
body: JSON.stringify({
address, subject, body
})
}).then(function (response) {
if (response.status >= 200 && response.status < 300)
return response.text();
else
throw new Error(response.statusText);
});
}

FRONT END:
import {sendEmail} from ‘backend/sendEmail.jsw’;
$w.onReady(function () {
sendEmail(“address@hotmail.com”, “Test”, “Test”.then (product => {
console.log( "OK: "+product );
})
.catch(error => {
console.log( "ERROR: " +error );
});
});

Hi,

First of all, you’re missing a closing parentheses (Before ‘.then’ in the Front End code).
Secondly,
I suggest using a real email address for both Sender and Receiver (instead of some generic one or ‘Test’.)
Sendgrid has ways to determine whether a message should be delivered, marked as SPAM, or just denied.
Try sending it from your own address to your own address, should work.

Liran.

I tried SendGrid but it’s not a free service. I will be sending less than 20 mails a month so I don’t require a batch service and I’d prefer it it were free. I just noticed that the closed parenthese is just a Typo while I was recopying the code. I tried sending it to myself, but to no avail. Same result. :frowning:

This is the Console.log output after I execute the code:

OK: Zend Framework Tutorial

For more information please visit our API documentation at Mailin API docs