I am not receiving emails on Form Submit from my site page SUPPORT. I have checked and rechecked all videos and threads, but there seems to be no error in my code. Please help
Site Form Page : Supprt
Site : https://www.vktyre.com
Wix Id : egagan@gmail.com
The following are my codes
CODE
import {sendEmail} from ‘backend/email’;
$w.onReady( function () {
$w(“#dataset1”).onAfterSave(sendFormData);
});
function sendFormData() {
const subject = Support Form Entry from ${$w("#input1").value}
;
const body = Name: ${$w("#input1").value} \rCity: ${$w("#input3").value} \rMobile: ${$w("#input4").value} \rEmail: ${$w("#input5").value} \rTyre Size: ${$w("#input6").value} \rTyre Serial: ${$w("#input7").value} \rDealer: ${$w("#input8").value} \rCity of Purchase: ${$w("#input9").value} \rDate of Purchase: ${$w("#datePicker1").value} \rIssue: ${$w("#textBox1").value} \rFile: ${$w("#uploadButton1").value}
;
debugger ;
console.log(body);
sendEmail(subject, body)
.then(response=>console.log(response));
}
email.jsw
import {sendWithService} from ‘backend/sendGrid’;
export function sendEmail(subject, body) {
const key = “SG.DmXth5y6T2S8zvu0B_Y3OQ.NWPxxxxMSHczGRmd2Yk40gglhGtpTOkoNG-Dj0-xxxx”;
const sender = “sanjay@vktyre.com”;
const recipient = “info@vktyre.com”;
return sendWithService(key, sender, recipient, subject, body);
}
sendGrid.js
import {fetch} from ‘wix-fetch’;
export function sendWithService(key, sender, recipient, subject, body) {
const url = “https://api.sendgrid.com/api/mail.send.json”;
const headers = {
“Authorization”: “Bearer” + key,
“Content-Type”: “application/x-www-form-urlencoded”
};
const data = from =${sender}&to=${recipient}&subject=${subject}&text=${body}
;
const request = {
“method”: “post”,
“headers”: headers,
“body”: data
};
return fetch(url, request)
.then(response => response.json());
}