'Program in local works fine but when I run as chrome extensio I get errors

I make a chrome extension that sends an email when you press a button whish is from an external site. When I run the program in localhost I get no errors. But when I run it as a chrome-extension I get errors like

**Uncaught ReferenceError: Email is not defined
    at sendEmail (popup.js:8:10)
    at popup.js:4:33**

Here is the file that I run in Localhost and it works fine: My html file:

<!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial- 
 scale=1.0">
     <script src="https://smtpjs.com/v3/smtp.js" defer></script>  
    <script src="popup.js" defer ></script>  
    </head>
    <body>
     <button id='hello'>press</button>
    </body>
    </html>

My javascript file:

    console.log('EXTENSION GO!!!')
    
    var button = document.getElementById('hello');
    button.addEventListener('click',sendEmail())
    
        function sendEmail() {
          
             Email.send({
                Host: "A server",
                Port:587, 
                 Username : "Email",
                Password : "password",
                To : 'Email',
                From : "Email",
                Subject : "Email 2",
                Body : "Hello",
            }).then(
    message => alert(message)
    );
        
        }

and my manifest:

    {
      "manifest_version":3,
      "name":"Edupass",
      "version":"0.01",
      "content_scripts":[
    {
      "matches":["<all_urls>"],
      "js":["popup.js"]
    }
    ],
    
    "action": {
    "default_popup": "index.html"
    }
    }

And here is my chrome extension and the external web site:

My html file:

 <!DOCTYPE html>
    <html lang="en">
    <head>
      <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <script src="https://smtpjs.com/v3/smtp.js" defer></script>  
    <script src="popup.js" defer ></script>  
    </head>
    <body>
     
    </body>
    </html>

My javascript file:

 console.log('EXTENSION GO!!!')
    
    var button = document.getElementById('hello');
    button.addEventListener('click',sendEmail())
    
        function sendEmail() {
          
             Email.send({
                Host: "A server",
        Port:587, 
        Username : "Email",
                Password : "password",
                To : 'Email',
                From : "Email",
                Subject : "Email 2",
                Body : "Hello",
            }).then(
    message => alert(message)
    );
        
        }

and my manifest file:

{
  "manifest_version":3,
  "name":"Edupass",
  "version":"0.01",
  "content_scripts":[
{
  "matches":["<all_urls>"],
  "js":["popup.js"]
}
],

"action": {
"default_popup": "index.html"
}
}

And the external

<html lang="en">
<head>
    <meta charset="UTF-8">

    <title>Subject</title>
<script src="scetch.js" defer></script>
</head>
<body>
    <button id="hello">Press it</button>


</body>
</html>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source