[英]How do I send an email using Javascript?
How do I send email using JavaScript? 如何使用JavaScript发送电子邮件?
I don't want to use mailto, because if I use mailto it will open an email client. 我不想使用mailto,因为如果我使用mailto,它将打开一个电子邮件客户端。
I agree with @Matchu. 我同意@Matchu。 Sending email requires server side languages and Javascript is client side languages.
发送电子邮件需要服务器端语言,而Javascript是客户端语言。 In this case, the best way would be to use PHP.
在这种情况下,最好的方法是使用PHP。 When you'll PHP you've lot's of the option to send an email how you like.
使用PHP时,您可以选择发送自己喜欢的电子邮件。 Here's the relevant example which you can use to send an email by using the PHP default
mail()
function. 这是相关示例,您可以使用PHP默认的
mail()
函数来发送电子邮件。
<?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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.