Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send email by using javascript or jquery

People also ask

Can I send email using JavaScript?

Can I send emails with JS or not? You can't send emails using JavaScript code alone due to lack of support for server sockets. For this, you need a server-side language that talks to the SMTP server. You can use JS in conjunction with a server script that will send emails from the browser based on your requests.

Can you send an email with jQuery?

You can't do it using JavaScript (jQuery is just a library) alone. You'd need a server-side handler to connect with the SMTP server to actually send the mail.

Can we send form content by email in JavaScript?

You can't. You will need to use some sort of background technology, such as python, ruby, coldfusion, php or ASP in order to send it to your email.


The short answer is that you can't do it using JavaScript alone. You'd need a server-side handler to connect with the SMTP server to actually send the mail. There are many simple mail scripts online, such as this one for PHP:

Simple PHP mail script

Using a script like that, you'd POST the contents of your web form to the script, using a function like this:

jQuery.post

And then the script would take those values, plus a username and password for the mail server, and connect to the server to send the mail.