Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending email from static html page

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)?

like image 580
rint Avatar asked Apr 16 '14 13:04

rint


People also ask

Can I send email from static website?

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.

How do you create a form in HTML and send it to email?

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.

How do you email HTML from a website?

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.

How do you send an email directly from a website?

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.


2 Answers

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

like image 162
Fizer Khan Avatar answered Oct 24 '22 04:10

Fizer Khan


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.

like image 31
Gwenc37 Avatar answered Oct 24 '22 05:10

Gwenc37