Send mail using javascript

0

I have a page that needs to send emails from the client using javascript. Until recently, the following instruction worked for me:

<a href="mailto:***@gmail.com?subject=Asunto del mensaje&body=Hola Es un nuevo correo">Enviar<a/>

But now it does not respond and it does not give an error either.

I've tried using

window.URL.revokeObjectURL

and

window.URL.createObjectURL

But only opens the Outlook with the data sent but does not send it (I must press the option to send).

    
asked by R Bru 04.01.2017 в 21:17
source

2 answers

2

what you want to do can not be done with javascript. you need a language like php or C # in MVC to be able to perform the mail sending process without using the outlook of the computer.

If you want to use the outlook it would work perfectly as you are using it. but if you want to send an email from the web you have to develop a mail module or use an email sending API that receives parameters and performs the work. You can search in Google, there are several.

    
answered by 04.01.2017 в 21:25
0

To send a mail you need a mail client since the browsers do not implement the SMTP protocol, it is impossible to do it in the browser.

Javascript is only a programming language and is subject to the restrictions of the platform where the interpreter is executed, in this case the platform is the browser.

Therefore the only alternative you have to send emails from the browser is to call the client as Outlook in Windows or Mail in macOS depending on the mail client installed in the operating system ... if you still want to manage the sending of mail yourself and do not go through these clients what you can do is implement the mail server on your server that sends from the server by SMTP the emails and if you want it to be with Javascript then you use Node.js, but this is a very complicated for the case you present.

    
answered by 04.01.2017 в 22:29