0

I have above script, i want to send email with remote ip address

but am getting error that ip address not defined

this error: Uncaught ReferenceError: ip is not defined

<!DOCTYPE html>
<html>

<head>
    <title>Sending Mail</title>
    <script src="https://smtpjs.com/v3/smtp.js"></script>
    <script src="https://api.ipify.org?format=jsonp&callback=getIP"></script>
    <script>
        function getIP(json) {
            var ip = ("public IP address which is: " + json.ip);
        }
    </script>
    <script type="text/javascript">
        function sendEmail() {
            Email.send({
                Host: "smtp host",
                Username: "smtp username",
                Password: "12345",
                To: 'recpt',
                From: "from",
                Subject: "hey",
                Body: `My ip is: ${ip}`,
            }).then(
                message => alert(message)
            );
        }
    </script>
</head>

<body>
    <form method="post">
        <input type="button" value="Send Mail" onclick="sendEmail()" />
    </form>
</body>

</html>
ulou
  • 5,542
  • 5
  • 37
  • 47
Jeff Docm
  • 15
  • 2
  • 4

0 Answers0