I have been researching for that problem for many hours, and didn't find anything.
So, I have a static html page and button inside it, like that:
<body>
<button id="0">SEND EMAIL TO [email protected]</button>
</body>
And if I press this button, message "Hello" will be sent to [email protected]
from [email protected]
Is it possible to do that thing using only html or javascript or jquery (because i know only that languages)?
nope.. you can't. For that you have to add a simple mail script using PHP. No need to learn full PHP for that, w3schools.com/Php/php_mail.asp here is small tutorial. html can't send emails, It's not a programming language, it's a markup language.
Pair PHP and HTML The more complex way to create a form in HTML and send it through email involves something called PHP, or Hypertext Preprocessor. You can use PHP code to create form fields for a “Contact Us” page where users can fill in their name, email, and message.
Click the main text box in the "Compose" window, then press Ctrl + V (Windows) or ⌘ Command + V (Mac). The HTML page's content will appear in the email exactly as it was formatted on the HTML page. Send your email. Click the Send button in the "Compose" window to do so.
There are 2 basic ways you can send an email from a web page: with the built in HTTP method using the 'mailto' attribute of a hyperlink or by using a server side script.
There are three ways to do it
Harder Way
You have to implement server code to send a mail
Less Harder Way
You have to use mailgun or sendgrid rest api to send a mail using javascript.
Simpler Way
You have to use https://formspree.io/ to send a mail from your HTML.
Update: Recently I found a way to send email using Google script. You don't need the backend. Explained here https://github.com/dwyl/html-form-send-email-via-google-script-without-server
You can use :
<body>
<a href = 'mailto:my@email?body="Yourbody"&subject="a subject".com'>SEND EMAIL TO [email protected]</a>
</body>
It will open a mail manager (outlook, gmail, ...) to send a new mail. You can describe the body and the subject inside the link
Otherwise you can send data to PHP with a form tag and send an email this PHP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With