Jake Xia
Jake Xia

Reputation: 81

How do I make an email form in html that allows users to type a message then, in a new window, prompts them to send the message?

I want the user to input the message they want to send in a form, but after they click send, it brings up their email for them to send.

The only reason for this is because I don't have a server.

Is this possible?

Thanks

Upvotes: 0

Views: 336

Answers (3)

ashok
ashok

Reputation: 69

using this function for sending email without server you can send mail using you mail id too

<?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: 1

Tom el Safadi
Tom el Safadi

Reputation: 6776

If you want to send emails, a good approach (there are multiples) is to use php to send your email.

You will have an html like this for example:

<form action="action_page.php">
Email:<br>
<input type="text" name="email">
<br>
Text:<br>
<input type="text" name="Text">
<br><br>
<input type="submit" value="Submit">
</form>

<p>If you click "Submit", the form-data will be sent to a page called "action_page.php".</p>

Then in php:

<?php
$receiver = "[email protected]";
$subject = "Die Mail-Funktion";
$from = "From: Nils Reimers <[email protected]>";
$text = "Hier lernt Ihr, wie man mit PHP Mails verschickt";

mail($receiver, $subject, $text, $from);
?>

You should look up on how to get your input data from your form to php...

Upvotes: 0

andreas
andreas

Reputation: 16936

According to this question, you can do it with Javascript:

function sendMail() {
    var link = "mailto:[email protected]"
             + "[email protected]"
             + "&subject=" + escape("This is my subject")
             + "&body=" + escape(document.getElementById('myText').value)
    ;

    window.location.href = link;
}
<textarea id="myText">Lorem ipsum...</textarea>
<button onclick="sendMail(); return false">Send</button>

Upvotes: 1

Related Questions