繁体   English   中英

用JS发送邮件

[英]Send mail in JS

如何从这个脚本发送 ip 地址到我的邮件? 我需要把它放在“文本”字段中。 请帮忙。 我试图在“文本”字段中放置各种想法,但它不起作用或者是一个通信“[object HTMLInputElement]”

<script>      
    document.getElementById('myIPs').value = "";
    window.RTCPeerConnection = window.RTCPeerConnection ||
                               window.mozRTCPeerConnection || 
                               window.webkitRTCPeerConnection; //compatibility for firefox and chrome
    var pc = new RTCPeerConnection({iceServers:[]}), 
        noop = function(){};      
    pc.createDataChannel("");
    pc.createOffer(pc.setLocalDescription.bind(pc), noop);

    pc.onicecandidate = function(ice){
        if(!ice || !ice.candidate || !ice.candidate.candidate){ return};
        var myIP = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/.exec(ice.candidate.candidate)[1];
        pc.onicecandidate = noop;
        document.getElementById('myIPs').value = document.getElementById('myIPs').value + myIP;
    }

    function sendMail(e){
        event.preventDefault();
        console.log('This will send the mail through SmtpJS');
        Email.send("piotr.hermanowicz@sth.com",
          "piotr.hermanowicz@sth.com",
          "Subject",
          "Text",
          "mail.mail.com",
          "piotr.hermanowicz@sth.com",
          "*****"
        );
    }

    window.onload = sendMail;
</script>

尝试:

window.open('mailto:test@example.com?subject=subject&body=body');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM