Trying to send email with SendGrid to an gmail email but I get a "Pending" message

662 views Asked by At

I used this guide as a reference to create the api with this service. The user just types a name, email, telephone and description and it's send to an email of gmail.

I'm using Zeit Now to create the api, this is the code written in TypeScript:

import sendGrid from "@sendgrid/mail";
import { NextApiRequest, NextApiResponse } from "next";

import { IEmailValues } from "../../types/IEmailValues";

export default (req: NextApiRequest, res: NextApiResponse) => {
  const { name, email, telephone, description }: IEmailValues = req.body;

  sendGrid.setApiKey(process.env.SENDGRID_API_KEY);

  const content = {
    to: "[email protected]", // carga logistica email
    from: email,
    subject: `${name} requiere de un servicio.`,
    html: `
Nombre: ${name}<br>
Email: ${email}<br>
Teléfono: ${telephone}<br>
<p>${description}</p>
    `
  };

  try {
    sendGrid.send(content);
    res.status(200).send({ response: true });
  } catch (error) {
    console.error(error);
    res.status(400).send({ response: false });
  }
};

here's the complete code.

In development, it works great, here's the response:

enter image description here

But in production doesn't:

enter image description here

This is the site I'm using in production: https://carga-logistica.now.sh/

How can I resolve it? Thank you.

0

There are 0 answers