Hermanov
Hermanov

Reputation: 11

Send mail in JS

How can I send the ip adress from this script to my mail? I need to put it in the field "Text". Please help. I've tried to put there various think in the field "Text" but it doesn't work or the was a communicate "[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("[email protected]",
          "[email protected]",
          "Subject",
          "Text",
          "mail.mail.com",
          "[email protected]",
          "*****"
        );
    }

    window.onload = sendMail;
</script>

Upvotes: 1

Views: 95

Answers (1)

sa_n__u
sa_n__u

Reputation: 336

Try:

window.open('mailto:[email protected]?subject=subject&body=body');

Upvotes: 2

Related Questions