Hi guys and mainly @giri-zano
Im desperate to get away from send grid due to undelivered mails to Hotmail due to some kind of black list or firewall.
I found the old post from @giri-zano i couldn’t reply as its closed.
https://www.wix.com/velo/forum/coding-with-velo/how-to-design-my-email-notification
I followed the code here however i get a error on send email
returns this error from JSW “Oops… API calls are disabled for non-browser applications” what does that mean? how do i fix it?
.catch((error) => {
console.log('Oops... ' + error);
});
}
//email_meal_plan_questionnaire.jsw
import {fetch} from 'wix-fetch';
export function sendEmail(emailprovider, template, params) {
const userid = "user_my id"; // put your emailjs userid here (look in Account)
const url = "https://api.emailjs.com/api/v1.0/email/send";
// if no email provider specified, then use this one
if (!emailprovider) {
emailprovider="service_xxx";
}
// if no email template specified, then use this one
if (!template) {
template="meal_plan_questionnaire";
}
let full_params = {
"user_id": userid,
"service_id": emailprovider,
"template_id": template,
"template_params": params
};
const headers = {
"Content-type": "application/json"
};
const request = {
method: 'POST',
headers: headers,
body: JSON.stringify(full_params)
};
return fetch(url, request)
.then((httpResponse) => {
if (httpResponse.ok) {
console.log('Your mail is sent!');
} else {
return httpResponse.text()
.then(text => Promise.reject(text));
}
})
.catch((error) => {
console.log('Oops... ' + error);
});
}
My submit button code
import {sendEmail} from 'backend/email_meal_plan_questionnaire';
let myprovider = "service_xxxx"; //use her the alias you used for this service in emailJS
let mytemplate = "meal_plan_questionnaire"; //use her the template name you defined in emailJS
let myparams = {
"first_name": $w('#firstNametextbox').value,
"last_name": $w('#lastNametextbox').value,
"dob": $w('#DOBdatePicker').value,
"weight": $w('#weightTextbox').value,
"email_address": $w('#emailAddresstextbox').value,
};
sendEmail (myprovider, mytemplate, myparams);
}
Many thanks
Dan