Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting 250 OK status Delivered from SendGrid, but the email never ends up in the mailbox

function sendEmailVerification(username, email, destination, response, cb){

    // create a random number
    var email_url = security.createEmailToken(username, email);

    // create a new URL for the verify call that will go into the email
    link=PROTOCOL+"://"+destination+"/verify?token="+email_url;

//      to : request.query.to,
   var verifyEmail = new sendgrid.Email();
    verifyEmail.addTo(email);
    verifyEmail.setSubject('Verify your email with example.com.');
    verifyEmail.setFrom('[email protected]');
    verifyEmail.setText(link);
    verifyEmail.setHtml(link);

    verifyEmail.addFilter('templates', 'enable', 1);
    verifyEmail.addFilter('templates', 'template_id', '3cf3g721-4a31-4fd1-a862-408707e18c96');

    logger.debug("send: mail options for user: " + JSON.stringify(verifyEmail));

    // use the smtp transport to send the email
    sendgrid.send(verifyEmail, function(error, resp) {
        if (error) {
            logger.error(error);
            response.status(500).send("A backend email send error occurred.");
            response.end();
        } else {
            logger.debug("Message sent: " + resp.message);
            response.status(200).send("email sent");
        }
        cb();
    });
}

What am I doing wrong? It seems the client service is not accepting my emails. Is it a problem with the headers? I am attempting to send a verification email with a SendGrid template.

Any suggestions are greatly appreciated, and thank you ahead of time!

like image 940
Dana Avatar asked Oct 14 '25 09:10

Dana


1 Answers

Have you checked your Email Activity on your SendGrid account?

There's two big steps to mail delivery: You passing the message to SendGrid (the 200 OK Martyn is talking about), and SendGrid attempting to deliver the message for you (ideally, the 250 Delivered event).

If you're getting a 250 Delivered event, but not seeing it on the recipient side, that means the mail server is accepting the message from SendGrid, but not giving it to the recipient for some reason. Unfortunately, SendGrid can't see any further than the Delivered event, so you'd have to talk to the mail admin of the receiving server to see what's happened with the message.

like image 119
jacobmovingfwd Avatar answered Oct 17 '25 03:10

jacobmovingfwd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!