GCHAINED EMAILER


GChained Mailer: The Future of Decentralized Mailing

Introduction 
GChained Mailer is a groundbreaking decentralized mailing system that integrates **SheetDB.io, EmailJS, Google Sheets, Google Drive, Jotform, and Airtable** into one seamless solution. This system allows users to send, store, and manage emails in a decentralized format, ensuring security, transparency, and efficiency.  

By merging **Google Sheets with SheetDB.io**, users can generate an API link that connects to **EmailJS**, enabling automated email sending and data storage. This powerful combination ensures that every mail sent is logged in a **decentralized database**, making it perfect for businesses, marketing campaigns, and record-keeping.  

---

## **How GChained Mailer Works**  

GChained Mailer uses a combination of JavaScript, HTML, Tailwind CSS, Bootstrap, and SVG icons to create a fully functional and aesthetically pleasing user interface. Below, we explore the technical details of how the system works.

### **1. Storing Emails in a Decentralized Format using SheetDB.io**  
The system first collects **user input** (name, email, phone number, and message) and then stores it in a **Google Sheet**. Using **SheetDB.io**, this sheet is converted into an API endpoint, allowing us to store and retrieve emails dynamically.

Here’s the JavaScript function that **stores emails in the SheetDB.io database**:

```html
<pre>
&lt;script&gt;
function chan() { 
    const caned = document.getElementById('caned');
    met++;

    if (met > 0.1) {
        caned.className = "fa fa-success"; 
        met = 0;
    } else {
        caned.className = "fa fa-primary"; 
    }

    // Collecting user input
    const fullName = document.getElementById("user").value;
    const email = document.getElementById("email").value;
    const phone = document.getElementById("phone").value;
    const message = document.getElementById("message").value;

    // Sending user input to SheetDB.io API
    fetch('https://sheetdb.io/api/v1/Add_Your_Sheetdb_Id', {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            data: [
                {
                    'name': fullName,
                    'email': email,
                    'phone': phone,
                    'message': message
                }
            ]
        })
    })
    .then((response) => response.json())
    .then((data) => alert('Message sent successfully!'));
}
&lt;/script&gt;
</pre>
```

### **Breaking Down the Code:**  
1. **Fetching user input**: The function collects name, email, phone, and message from the form.  
2. **Storing in SheetDB.io**: The data is sent to a Google Sheet (converted into an API with SheetDB.io).  
3. **Success Alert**: After a successful submission, the user receives a confirmation message.  

---

## **2. Automating Email Notifications with EmailJS**  
Once the data is stored in **SheetDB.io**, the system automatically retrieves new data and sends an email notification to a designated email address using **EmailJS**.  

### **Code for Fetching Data & Sending Emails Automatically**  

```html
<pre>
&lt;script&gt;
emailjs.init("Emailjs_Public_Key"); // Replace with your EmailJS Public Key

const apiUrl = "https://sheetdb.io/api/v1/Add_Your_Sheetdb_Id";  
let lastData = null;

async function fetchData() {
    try {
        document.getElementById("loader").style.display = "block";

        const response = await fetch(apiUrl);
        const data = await response.json();

        // If new data is found, send an email
        if (JSON.stringify(data) !== JSON.stringify(lastData)) {
            lastData = data;
            sendEmail(data);
        }

        document.getElementById("loader").style.display = "none";
    } catch (error) {
        console.error("Error fetching data:", error);
    }
}

// Function to send an email when new data is detected
function sendEmail(data) {
    const emailContent = JSON.stringify(data, null, 2);

    const emailParams = {
        to_email: "sheunfunmilolashola@gmail.com", // Replace with recipient email
        subject: "SheetDB Update Notification",
        message: emailContent
    };

    emailjs.send("Emailjs_Service_Id", "Emailjs_Template_Id", emailParams)
        .then(response => {
            console.log("Email sent successfully!", response);
        })
        .catch(error => {
            console.error("Email sending failed!", error);
        });
}

// Check for new data every 10 seconds
setInterval(fetchData, 10000);
fetchData();
&lt;/script&gt;
</pre>
```

### **Breaking Down the Code:**  
1. **EmailJS Initialization**: The system initializes EmailJS with an API key.  
2. **Fetching Data from SheetDB.io**: The script continuously fetches data from the API every **10 seconds**.  
3. **Detecting Changes**: If new data is found, it triggers the `sendEmail()` function.  
4. **Sending Email Notifications**: The new data is formatted and sent via **EmailJS** to the designated recipient.  

---

## **3. Frontend UI: A Masterpiece of Design**  
The GChained Mailer landing page is crafted with **HTML, Tailwind CSS, Bootstrap CSS, and SVG icons**. The UI is **aesthetic, elegant, and professional**, ensuring a premium user experience.

### **Key Features of the Frontend:**  
✅ **Stunning, Artistic Design** – A well-crafted, visually appealing interface.  
✅ **Easy-to-Use Form** – Users can enter their details and send messages instantly.  
✅ **Real-Time Notifications** – Automatic updates ensure users receive confirmations.  
✅ **Secure & Decentralized** – Emails and messages are stored in a **Google Sheet** via **SheetDB.io**, making it **tamper-proof**.  
✅ **Optimized for Speed** – The page is lightweight, responsive, and fast-loading.  

---

## **4. How Everything Works Together**  
GChained Mailer seamlessly integrates **Google Sheets, SheetDB.io, EmailJS, Jotform, Airtable, and Google Drive** into a **single, decentralized** email management system.  

**Workflow:**  
1️⃣ **User fills the form** → Data is sent to **SheetDB.io** via **Google Sheets**.  
2️⃣ **SheetDB.io stores the data** in a decentralized format.  
3️⃣ **Automated script fetches new data** every **10 seconds**.  
4️⃣ **EmailJS sends an email notification** to the admin when a new message arrives.  
5️⃣ **All data is stored securely and can be retrieved anytime.**  

---

## **Conclusion**  
GChained Mailer is a revolutionary approach to **decentralized email management**. By combining **Google Sheets, SheetDB.io, and EmailJS**, it ensures that every email sent is **securely stored**, making it ideal for businesses, marketing campaigns, and secure communication.  

This system proves that **decentralized technology** can be applied to **email communication**, reducing reliance on traditional email servers while **enhancing security and transparency**.  

💡 **Are you ready to experience the future of decentralized mailing? Start using GChained Mailer today!** 🚀



Comments

Popular Posts