Hi,
What are you trying to achieve? please share the code you are using so we can inspect.
Hi,
i am trying to send email with sendgrid api key.
I can’t send mail my personal email from my website.
i got the api code .Please help.
//email.jsw
import {sendWithService} from ‘backend/sendGrid’;
export function sendEmail(subject, body) {
const key = “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”;//my new API key
const sender = “info@mydomain.com”;//my personal email
const recipient = “to.email@domain.com”;
return sendWithService(key, sender, recipient, subject, body);
}
export function sendEmailWithRecipient(subject, body,recipient) {
const key = “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”;
const sender = “info@mydomain.com”;//my personal email
return sendWithService(key, sender, recipient, subject, body);
}
//SendGrid.js
// I didn’t change anything here
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());
}
Hi,
i am trying to send email with sendgrid api key.
I can’t send mail my personal email from my website.
i got the api code .Please help.
//email.jsw
import {sendWithService} from ‘backend/sendGrid’;
export function sendEmail(subject, body) {
const key = “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”;//my new API key
const sender = "info@mydomain.com ";//my personal email
const recipient = "to.email@domain.com ";
return sendWithService(key, sender, recipient, subject, body);
}
export function sendEmailWithRecipient(subject, body,recipient) {
const key = “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”;
const sender = "info@mydomain.com ";//my personal email
return sendWithService(key, sender, recipient, subject, body);
}
//SendGrid.js
// I didn’t change anything here
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());
}
Hi, Do you received and error in the console?
Roi.
i solve this problem.i changed all of the emails and i just made my own email adress.
//email.jsw
import {sendWithService} from ‘backend/sendGrid’;
export function sendEmail(subject, body) {
const key = “SG.rTZdkPkjTYqhey10RpPZXg.QVLM0mOrPxMu0ZuyG2o9i5MCIUNHkQeTE_NUFhsT”;//my new API key
const sender = "info@mydomain.com "; //my personal email
const recipient = " info@mydomain.com " ;
return sendWithService(key, sender, recipient, subject, body);
}
export function sendEmailWithRecipient(subject, body,recipient) {
const key = “SG.rTZdkPkjTYqhey10RpPZXg.QVLM0mOrPxMu0ZuyG2o9i5MCIUNHkQeTE_NUFhsT”;
const sender = "info@mydomain.com " ;//my personal email
return sendWithService(key, sender, recipient, subject, body);
}
But i have a new problem about sending email.I created a new form elated to sending an email.
In this js. code i wrote a mail that hotmail or gmail form is sending success.
$w.onReady( function () {
//TODO: write your page related code here…
});
import { sendEmail, sendEmailWithRecipient } from ‘backend/email’;
$w.onReady( function () {
$w(“#button3”).onClick(sendFormData);
});
function sendFormData() {
const subject = Information Form
;
const body = ${$w("#input8").value}...
;
const recipient = “info@mydomain.com”;
sendEmailWithRecipient(subject, body, recipient)
.then(response => console.log(response));
sendEmail(subject, body)
.then(response => console.log(response));
}
But i have a new problem about sending email.I created a new form related to sending an email.This code, sending a mail with hotmail or gmail successed.But my domain’s email not sending.
I wonder if the mail settings have trouble ?
Note: mail sending does not receive an error.