How do I make a website send a message

I am making a website on Cloudflare about programming. anyways I wanted to make a Contact Me page. Where the user would write a message in a textarea and when he presses a button, it would send the message to me via email. Can someone help me in doing that

1 Like

You would likely need a backend connected to a smtp server, or using an email api like https://sendgrid.com/pricing/

1 Like

Use Flask, and see the Client Server Logins Day (I think) on 100 days of Code for the data to be stored in Python. Also see Day 98 (Automate! Automate!) to send emails, or check out my email sender project using Day 98 that I published (my username is @NateDhaliwal ).
If I am not wrong it all can be done.

1 Like

Hi kareem,

You can watch some YouTube tutorials about EmailJS API to implement it into your code. THis works with bootstrap as well. Hope it helped!

(You will need to create an account and create an email template)

1 Like

Hi there,

I just did this like a month ago. I have a very simple solution using Gmail if you would like it sent via that. And it’s front-end only, meaning it’s very simple to implement. Below are the steps.

First login to the Gmail/Google account you want the emails to send from.

Go to script.google.com (press Start Scripting if you see that button.) Press New Project.

Delete all the code in the code box already and replace it with this:

function doGet(e) {

    var data = e.parameter["q"];
    data = JSON.parse(data)

    var emailAddress = data[0]
    var subject = data[1]
    var message = data[2]

    try {
        MailApp.sendEmail(emailAddress, subject, message);
        return ContentService.createTextOutput(true);
    } catch (error) {
        return ContentService.createTextOutput(error.message);
    };

};

Then press the save project in the toolbar, just left of the Run button.

Then press the big blue Deploy button and click New Deployment.

Click the Settings gear next to Select Type, press web app.

Where it says Who has access, change from Only Myself to Anyone.

Press Deploy.

Where it says Web App URL, press Copy.

Paste the URL into the below variable, and use the below JavaScript code anywhere in your site to send the email. Adjust the three strings in the request accordingly. (E.g. putting the textbox value from a contact form.

var url = "Paste the URL here";

fetch(url + "?q=" + JSON.stringify([
  "Put the user's email here (whether it be from an input or something else)",
  "Subject Line",
  `Message`
])).then(() => {
  // here you can let the user know their contact was received
});

I hope this helps! I might not have sent this if you had already found the other solutions helpful, but I think this is the easiest way to set up a contact form or even bug reporting stuff.

4 Likes

Just to let you know, I believe you can send 20,000 emails per day (with a non-Google-Workspace Gmail account) and you can send emails to a max of 100 different people per day (e.g., a max of 100 different people can submit your form with their email, but they can send multiple emails until the daily email limit is reached.)

Source: https://developers.google.com/apps-script/guides/services/quotas

3 Likes

Thank you very much but I found a way to do it with Formspark but tysm for the help

1 Like

This is a great suggestion @boston2029 thank you for sharing!

4 Likes