I need urgent help as I am working on a deadline for this website. I did the sendgrid set up and no emails are coming through. I will change the API Key when this gets resolved. See my Screenshots below. I have been working on this for 4 days. I've tried everything
top of page
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
bottom of page
Hi, I also facing similar problem. I have checked and rechecked all the codes. Every thing is fine. My Sendgrid API key is also valid. But emails are not received. My webiste at WIX is https://www.vktyre.com
and user ID is egagan@gmail.com
Page 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.NWP6rxxxxHczGRmd2Yk40gglhGtpTOkoNG-Dj0-xxxx"; const sender = "egagan@gmail.com"; const recipient = "vke.india@gmail.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()); }
PLESAE HELP
Hello!
I'm having the same issue, have read the codes a thousand times, sarched for case mismatches in filenames, tried changing IDs, API keys, language in Sendgrid configs, and a bunch of other stuff. I'm no expert so I've run out of options, so I'd like some help..
I'm seeing no errors in console, no email is delivering (or even being sent, as SendGrid activity is still empty).
My page is https://www.wbarmarios.com.br/fale-conosco
Maybe i'm missing some small detail, or is a misconfiguration somewhere else, I'm hoping someone might identify it.
Thanks in advance!
On the Matchmaker and Sell tabs (both located under the Shop main tab) are custom forms using a SendGrid API. I am not receiving email notifications after form submissions, although the form data is stored successfully in the databases. Can someone help identify the notification problem?
This is the site --> https://www.15hours.com/
Thanks!
I figured this out. It was my page code. I posted the working version here: https://www.wix.com/code/home/forum/questions-answers/contact-form-with-sendgrid
--Al
I am trying to send mail from my own "contact us" form. I believe that I have used basically all of the same code, except I am not saving the information to a database. I'm just trying to send it in an email. I followed this article: https://support.wix.com/en/article/how-to-send-an-email-on-form-submission. I have a SendGrid API-Key (I've actually tried two with an equal lack of success). This is my page code:
// libraries that we need import wixData from 'wix-data'; // Used to query database //import wixLocation from 'wix-location'; // Used to get current page URL import wixUsers from 'wix-users'; // Used to get the current user import {sendEmail, sendEmailWithRecipient, sendEmailWithRecipientAndSender} from 'backend/email'; //import {sendEmailWithRecipientAndSender} from 'backend/email'; // This page is set as members only; so we just need to find out which member this is... // and fill out the name and from email input fields, which are the first two // on the form. The other fields are another input field for subject and // a text box for the message body. $w.onReady(function () { // Grab the current user's ID let user = wixUsers.currentUser; let userId = user.id; // Grab user ID. could just set userId = wixUsers.currentUser.id // Get this user's name and email, and put it in the appropriate inputs wixData.query("OurTest") .eq('_id', userId) .find() .then( (results) => { $w('#input1').value = results.items[0].userName; $w('#input2').value = results.items[0].email; } );}); // Check that they don't have empty subject and message and send export function button1_click() { if (($w('#input3').value !== "") && ($w('#textBox1').value !== "")){ sendMsgData; $w('#input3').value = ""; $w('#textBox1').value = "Message Sent"; } else{ $w('#input3').value = "Subject Required!"; $w('#textBox1').value = "Message Required!"; } } function sendMsgData() { let user = wixUsers.currentUser; let userId = user.id; wixData.query("OurTest") .eq('_id', userId) .find() .then( (results) => { const sender = results.items[0].email; const recipient = results.items[0].sendEmail; const subject = `New Mesage from ${$w("#input1").value}`; const body = `Name: ${$w("#input1").value} \rEmail: ${$w("#input2").value} \rSubject: ${$w("#input3").value} \rMessage: ${$w("#textBox1").value}`; debugger; console.log(body); console.log (recipient); sendEmail(subject, body) .then(response => console.log(response)); }); //sendEmailWithRecipientAndSender(subject, body, recipient, sender) //.then(response => console.log(response)); // }); }
Eventually, I want to be able to specify the recipient and the sender (which I am grabbing out of my database). Right now, I've gone back to just the basic sendEmail and hard coded my email into the sendEmail function in backend/email. I added the debugger and console calls shown in this post, but I don't see any results in the console log. Am I not handling the onClick properly for my button? At the moment, I seen to have broken my if statement; so I probably should go look at something else for a while...:(
Thanks--
Al
Hi Adrian,
I need some more information.
Do you have your own API key?
Can you tell me if you see any console errors?
Did you make any changes to the sample code?
If so, which?
Liran.
Hey there!
I seem to be having the same problem. It doesn't show up in my inbox. I used the site tutorial which looks very similar to the code published in the first post. Would you be able to help?
https://adrian7130.wixsite.com/theblackboxsa/cloudquoting/Ash
Ok. I'll Try both and test how it goes. Thanks!
Redirect after sending mail will be in page code:
import {sendEmail} from 'backend/email'; import wixLocation from 'wixLocation'; $w.onReady(function () { $w("#dataset1").onAfterSave(sendFormData); }); function sendFormData() { const subject = `Type Your Subject Here ${$w("#input1").value}`; const body = `Type Here: ${$w("#input1").value} \rLabelHere: ${$w("#input2").value} \rLabelHere: ${$w("#input3").value} \rLabelHere: ${$w("#input4").value} \rReason: ${$w("#textBox1").value}`; sendEmail(subject, body).then(response => { wixLocation.to('/home'); }); }
Please read and adjust.
regarding some mails, please read here: https://support.wix.com/en/article/how-to-send-an-email-on-form-submission
The part of 'Backend code', where the recipient is a parameter to the function.
Liran.
Liran, Just tested the redirect. It did break it. I need this for almost all the forms I am going to use this with so I need a solution. Do I just put the Url of the location and do I put it in the page part of the code? Please help. Additionally, how can I incorporate a second email to the submitter of the form. Would I be able to add this to the JSW file?: export function sendEmailWithRecipient(subject, body, recipient) {
const key = "MY KEY";
const sender = "shchamberweb@gmail.com";
return sendWithService(key, sender, recipient, subject, body);
}
And this to the page code?: sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
Did you remember to put your own API key?
Here's the code:
Liran.
I just tried to submit using my own computer and nothing happened. I saw the file name change. Can you just send the code as I should type it?
In the site you gave me.
Also, note that I removed the link from the button (the one that takes to /home).
Try adding it back, and if it breaks the email sending, use wixLocation.to() for redirection.
Liran.
Wait what? Did you go into my site? Where did you save it?
Just copy from the site that you posted here, I've saved the changes.
please note the file names (e.g. sendGrid) - it's case sensitive.
Liran.
It worked! My inbox is full. What are the code updates so that I can implement it?
Hi,
So I was able to send a mail (fixed the filename mostly).
Please check your email (the one you configured in the code: sh....web), as I sent a few to it :)
I saved the site. all you need to do now is put your own API key.
Liran.
Liran,
Is that everything you need? Let me know how else I can help.
I started fresh with this one so I am just using a template. I will import my other items later and change the design. https://shchamberweb.wixsite.com/redo/form-test
Can you please share a url to your site?