Sanjay Shah
Sanjay Shah

Reputation: 2809

How do I send an email using Javascript?

How do I send email using JavaScript?

I don't want to use mailto, because if I use mailto it will open an email client.

Upvotes: 2

Views: 1256

Answers (2)

mmik
mmik

Reputation: 5961

I agree with @Matchu. Sending email requires server side languages and Javascript is client side languages. In this case, the best way would be to use PHP. When you'll PHP you've lot's of the option to send an email how you like. Here's the relevant example which you can use to send an email by using the PHP default mail() function.

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n" .
    'Reply-To: [email protected]' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);

Upvotes: 0

Matchu
Matchu

Reputation: 85784

Can't be done. Sending e-mail only works on the server side. If all you're doing is sending e-mail, a quick PHP script would likely do the trick.

Upvotes: 6

Related Questions