Skip to content

RadyaI/send-email

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple Email Sender API

API sederhana untuk mengirim email menggunakan Node.js, Express, dan Nodemailer.

Endpoint

POST /sendemail

  • Description: Mengirim email.

  • Request Body:

    {
      "emailTo": "recipient@example.com",
      "subject": "Your Subject",
      "text": "Your email content",
      "pass": "your_secret_password"
    }
    • emailTo: Alamat email penerima.
    • subject: Subjek email.
    • text: Konten email.
    • pass: Password rahasia yang harus sama dengan YOUR_PASS di file .env.
  • Response:

    • Berhasil: Status 200
      {
        "message": "Email berhasil dikirim!"
      }
    • Gagal: Status 400 atau 500
      {
        "message": "Gagal mengirim email.",
        "error": "Error details"
      }

Contoh Request Menggunakan Fetch di JavaScript

fetch('http://localhost:3000/sendemail', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    emailTo: 'recipient@example.com',
    subject: 'Test Email',
    text: 'Hello from Simple Email Sender API!',
    pass: 'your_secret_password'
  })
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Catatan Penting

  • YOUR_PASS: Kamu perlu menambahkan variabel YOUR_PASS di file .env sebagai password rahasia untuk melindungi endpoint ini. Contoh:
    YOUR_PASS=your_secret_password

Made By

Radya

About

A simple API for sending emails effortlessly. Perfect for notifications or just saying hello via email.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published