Javascript-邮件 [英] Javascript - Mail

查看:131
本文介绍了Javascript-邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在文本区域中向其他许多用户发送电子邮件.在名为内容的文本区域中,如果我输入由星号包围的用户",我想用每封电子邮件的用户名("@"之前的文本)填充它们.每封电子邮件中的每个用户名都会产生许多不同的结果.然后,当我按下按钮时,我希望将所有电子邮件发送给每个相应的用户.到目前为止,这是我的邮件功能:

I want to send an email in a text-area to many other users. In the text-area, named content, if I typed "user" surrounded by stars, I want to have them filled in with each email's username (the text before the "@"). That would yield many different with each username in each email. Then when I hit a button, I want to have all the emails sent to each corresponding user. This is my mail function so far:

function mail(){
    var options = document.getElementById('users').options
    var emails = []
    for(var i = 2; i < options.length; i++){
        emails.push(options[i].innerHTML)
    }   
}

我该怎么做?谢谢!!!

How do I do this? Thanks!!!

推荐答案

不幸的是,无法使用JavaScript发送电子邮件,但是您可以使用PHP进行发送.在这里,您上面已将变量options放置在表单中,并通过POST通过input属性中的name="options"发送到POST页面:

Unfortunately it's not possible to send an email using JavaScript, but you can do it with PHP. Here, the variable options you have above has been placed in a form and sent to the PHP page via POST, with the name="options" in the input attribute:

<?php
    $options = $_POST['options'];
    $to = "person@example.com";
    $subject = "Random Life";
    $body = "Lorem ipsum dolor. $options";

    mail ($to,$subject,$body);

 ?>

这会将一封电子邮件发送给person@example.com,主题为Random Life,内容为Lorem ipsum dolor [options],其中options是表单传递的值.

This will send an email to person@example.com, with the subject Random Life, and the content Lorem ipsum dolor [options], where options is the value passed by the form.

但最终,不能,目前无法使用JavaScript 发送电子邮件.将来可能会出现这种情况,但目前尚不可用.

But in finality, no, it is not possible to send an email using JavaScript currently. It may be possible in future years, but currently not available.

这篇关于Javascript-邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆