Envias Correo Electrónicos gratis con Resend Emails

Hola comunidad! en esta ocasión les traigo un pequeño ejemplo para poder crear tu propía API, para envios de Correo Eleéctronico

Todo esto es gracias a RESEND

Video Implementación

Se instalan las diferente Librerías

npm i express bodyParser cor…


This content originally appeared on DEV Community and was authored by Yosmar Hinestroza

Hola comunidad! en esta ocasión les traigo un pequeño ejemplo para poder crear tu propía API, para envios de Correo Eleéctronico

Todo esto es gracias a RESEND

Video Implementación

Envias Correo Electrónicos gratis con Resend Emails<br>

Se instalan las diferente Librerías

npm i express bodyParser cors Resend dotenv

Se crea archivo server.js

import express from 'express';
import bodyParser from 'body-parser';
import cors from 'cors';
import { Resend } from 'resend';

const app = express();

app.use(cors());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

console.log(process.env.RESEND_API_KEY);
const PORT = process.env.PORT || 4002;
const resend = new Resend(process.env.RESEND_API_KEY ?? '')

app.get('/', (req, res) => {
    res.send('Hello World');
})

app.post('/send-email',  async (req, res) => {
    try {
        const { from, to, subject, html } = req.body;
        const response = await resend.emails.send({ from, to, subject, html });
        res.status(200).send(response);
      } catch (error) {
        res.status(500).send({ error: 'Failed to send email' });
      }
})



app.listen(PORT, () => {
    console.log(`Server is running on port localhost:${PORT}`);
});

En el archivo package.json editar la siguiente linea

"scripts": {
    "start": "node -r dotenv/config ./src/server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },


This content originally appeared on DEV Community and was authored by Yosmar Hinestroza


Print Share Comment Cite Upload Translate Updates
APA

Yosmar Hinestroza | Sciencx (2025-01-08T04:08:24+00:00) Envias Correo Electrónicos gratis con Resend Emails. Retrieved from https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/

MLA
" » Envias Correo Electrónicos gratis con Resend Emails." Yosmar Hinestroza | Sciencx - Wednesday January 8, 2025, https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/
HARVARD
Yosmar Hinestroza | Sciencx Wednesday January 8, 2025 » Envias Correo Electrónicos gratis con Resend Emails., viewed ,<https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/>
VANCOUVER
Yosmar Hinestroza | Sciencx - » Envias Correo Electrónicos gratis con Resend Emails. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/
CHICAGO
" » Envias Correo Electrónicos gratis con Resend Emails." Yosmar Hinestroza | Sciencx - Accessed . https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/
IEEE
" » Envias Correo Electrónicos gratis con Resend Emails." Yosmar Hinestroza | Sciencx [Online]. Available: https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/. [Accessed: ]
rf:citation
» Envias Correo Electrónicos gratis con Resend Emails | Yosmar Hinestroza | Sciencx | https://www.scien.cx/2025/01/08/envias-correo-electronicos-gratis-con-resend-emails/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.