Issue with the SendGrid Updated Policy

Hi, I’m trying to provide a feature on my website to send the email to a person by logged-in User. I’ve checked tried many things but the SendGrid showing an error - “The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit [Link] to see the Sender Identity requirements”

I’ve number of members on my website and unable to verify each member manually on SendGrid. So now is it possible to use SendGrid? Please help me asap.

Thanks in advance!

You need to add only one verified sender email and add logged-in user’s email in reply-to section because there is no possibility to add senders dynamically. You need to add logged-in member in reply-to section.

Thanks for the reply. But how to add every new logged-in user’s email dynamically? I’ve added the same email id in both sender & reply. It’s working if the “sender verified id” is same in wix form. Else, giving an error as sender id not verified.

Can you provide a code that you wrote for this? This will help me to resolve your issue.

Hi, Here is the code:

// Page Code

import { sendEmail } from ‘backend/sendEmail’ ;
import wixWindow from ‘wix-window’ ;
import wixUsers from ‘wix-users’ ;

$w . onReady ( function () {
wixUsers . currentUser . getEmail ()
. then ( ( email ) => {
$w ( ‘#fromEmail’ ). value = email ;
})

});

export function btnSend_click ( event , $w ) {
console . log ( $w ( “#toEmail” ). value + $w ( “#subject” ). value + $w ( “#fromEmail” ). value + $w ( “#emailContent” ). value );

if ( $w ( ‘#toEmail’ ). validity . valid === false )
return ;
if ( $w ( ‘#fromEmail’ ). validity . valid === false )
return ;
if ( $w ( ‘#subject’ ). validity . valid === false )
return ;
if ( $w ( ‘#emailContent’ ). validity . valid === false )
return ;

sendEmail ( 

        $w ( "#toEmail" ). value , 
        $w ( "#subject" ). value , 
        $w ( "#fromEmail" ). value , 
        $w ( "#emailContent" ). value ) 

. then (( res ) => {
let dataObj = {
status : “success” ,
email : $w ( ‘#toEmail’ ). value
};
console . log ( dataObj );
//wixWindow.openLightbox(“Message”, dataObj);
//$w(“#toEmail”).value = “”;
$w ( “#subject” ). value = “” ;
//$w(“#fromEmail”).value = “”;
$w ( “#emailContent” ). value = “” ;

//$w(“#toEmail”).resetValidityIndication();
$w ( “#subject” ). resetValidityIndication ();
//$w(“#fromEmail”).resetValidityIndication();
$w ( “#emailContent” ). resetValidityIndication ();
})
. catch (( error ) => {
console . log ( error );
let dataObj = {
status : “fail” ,
email : $w ( ‘#toEmail’ ). value
};
console . log ( dataObj );
//wixWindow.openLightbox(“Message”, dataObj);
})
}

// sendGrid.js

import { fetch } from ‘wix-fetch’ ;

const key = " 'SG… I used my API Key here" ;

export function sendWithService ( sender , recipient , subject , body ) {

const url = “[Link here - 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 ());
}

//sendEmail.jsw

import { sendWithService } from ‘backend/sendGrid’ ;

export function sendEmail ( recipient , subject , sender , body ) {
return sendWithService ( sender , recipient , subject , body );
}

Error: Mentioned in description

Please check this & let me know if I did something wrong.

add verified email ID in from section.
add new section named replyTo after body section and add loggedIn member’s email in that section. like this…

const data = `from=verified sender email here&to=${recipient}&subject=${subject}&text=${body}&replyTo=${loggedIn member email}`;

Thanks for the great help! However, the email always received from the verified sender email. Is this possible to receive from the logged member email?

@akgarg804 There is no possibility to do this. There is only possibility to use replyto section.

@team40951 Thanks for helping me out.