hello all
i would like to receive an email when someone submit a form.
regards
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.
Hi,
Do you receive an error?
Did you check the spam folder?
Roi.
i have used the API provided by sendgrid but still not working
Hi Siyamand Rashid.
In your posted example, it seems that the example uses the https://sendgrid.com/ service to send the email.
So the API key mentioned in the article should be retrieved from the sendgrid service.
Regards,
Genry.
Hey,
You can check out also the triggered email feature.
Best,
Tal.
there is an important Note: you have to modify your API key , where i get this key please may be that is why its not working?
regards
thanks for your reply,
i tried this way but didnt work for me !! , my codes as below could you please see where is the issue is ?
// Filename: backend/email.jsw (web modules need to have a .jsw extension)import {sendWithService} from 'backend/sendGrid'; import {sendWithService} from 'backend/sendGrid'; export function sendEmail(subject, body) { const key = "QL.cFH5YHZQQ2_fG0z_KuQ.6WPTYEyjN1C3_7Wt9Hb3jGfkJNAyzJhz3ddhM"; const sender = "siyamandm@gmail.com"; const recipient = "siamandm@gmail.com"; return sendWithService(key, sender, recipient, subject, body); } export function sendEmailWithRecipient(subject, body, recipient) { const key = "QL.cFH5YHZQQ2_fG0z_KuQ.6WPTYEyjN1C3_7Wt9Hb3jGfkJNAyzJhz3ddhM"; const sender = "siyamandm@gmail.com"; return sendWithService(key, sender, recipient, subject, body); }
and the 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()); }
and my page code is as below :
// For full API documentation, including code examples, visit http://wix.to/94BuAAs $w.onReady(function () { //TODO: write your page related code here... }); import {sendEmail, sendEmailWithRecipient} from 'backend/email'; $w.onReady(function () { $w("#dataset1").onAfterSave(sendFormData); }); function sendFormData() { const subject = `New Submission from ${$w("#SellerName").value}`; const body = `Name: ${$w("#SellerName").value} \rSport: ${$w("#currency").value} \rComments: ${$w("#info").value}`; // const recipient = $w("#emailInput").value; sendEmailWithRecipient(subject, body, ) .then(response => console.log(response)); }
There is a great sample on using SendGrid with Wix Code that will help you.
https://support.wix.com/en/article/how-to-send-an-email-on-form-submission