javascript – How to send emails with just the basics of HTML5

Question:

I'm building a website to be hosted on a server that doesn't support PHP or another server-side language.

I need to send the values ​​from a contact form via email and my features are HTML5 and JavaScript only .

Is there any way to make this submission?

Answer:

It is not possible to send with only HTML5 and JavaScript. To send an email you need an SMTP server .

This task is normally delegated to the web server ( server-side ), but as you explained you don't have it.

It is not possible to connect directly from a browser to an SMTP server (or any other service using a protocol other than HTTP, even for security reasons).


I don't know if this is your case, but an alternative would be to leave the job of sending the email to the user, using a URL with mailto .

You can even specify a subject and body of the email, for example:

<a href="mailto:?subject=Assunto do email&amp;body=Olá,%0D%0A%0D%0A[corpo do email]%0D%0A%0D%0AAtenciosamente,%0D%0A[nome do usuário]">Envie seu email!</a>

Note:

  • In the example %0D%0A represents a line break.
  • It is not possible to use HTML in the body of the email (explained here ).
Scroll to Top