如何在 html 中创建一个电子邮件表单,允许用户键入消息,然后在新的 window 中提示他们发送消息?
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?
我希望用户在表单中输入他们想要发送的消息,但在他们单击“发送”后,它会弹出他们的电子邮件供他们发送。
唯一的原因是因为我没有服务器。
这可能吗?
谢谢
根据 this question,您可以使用 Javascript:
function sendMail() {
var link = "mailto:me@example.com"
+ "?cc=myCCaddress@example.com"
+ "&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>
如果您想发送电子邮件,一个好的方法(有多个)是使用 php 来发送您的电子邮件。
您将有一个 html 例如:
<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>
然后在php:
<?php
$receiver = "empf@domain.de";
$subject = "Die Mail-Funktion";
$from = "From: Nils Reimers <absender@domain.de>";
$text = "Hier lernt Ihr, wie man mit PHP Mails verschickt";
mail($receiver, $subject, $text, $from);
?>
您应该了解如何将表单中的输入数据 php...
using this function for sending email without server you can send mail using you mail id too
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
我希望用户在表单中输入他们想要发送的消息,但在他们单击“发送”后,它会弹出他们的电子邮件供他们发送。
唯一的原因是因为我没有服务器。
这可能吗?
谢谢
根据 this question,您可以使用 Javascript:
function sendMail() {
var link = "mailto:me@example.com"
+ "?cc=myCCaddress@example.com"
+ "&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>
如果您想发送电子邮件,一个好的方法(有多个)是使用 php 来发送您的电子邮件。
您将有一个 html 例如:
<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>
然后在php:
<?php
$receiver = "empf@domain.de";
$subject = "Die Mail-Funktion";
$from = "From: Nils Reimers <absender@domain.de>";
$text = "Hier lernt Ihr, wie man mit PHP Mails verschickt";
mail($receiver, $subject, $text, $from);
?>
您应该了解如何将表单中的输入数据 php...
using this function for sending email without server you can send mail using you mail id too
<?php
$to = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>