Intruder alarm send Email

Hi

I want My alarm to send an email.
It´s works, but it keep sending mail, until the alarm is reset (pin2 stay HIGH).
It must send 1 email every time pin2 goes HIGH.
some suggestions?

#include <SPI.h>
#include <Ethernet.h>

// Set the panic button pin
byte panicButton2 = 2;
boolean statusCheck = false;
// this must be unique
byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };
// change network settings to yours
IPAddress ip( XXX, XXX, XXX, XXX );
IPAddress gateway( XXX, XXX, XXX, XXX );
IPAddress subnet( 255, 255, 255, 0 );

// change server to your email server ip or domain
// IPAddress server( 1, 2, 3, 4 );
char server[] = "XXX.XXX.XXX.XXX";

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin2 = 2;     // the number of the pushbutton pin
const int ledPin =  13;         // the number of the LED pin


EthernetClient client;

void setup()
{
  Serial.begin(9600);
  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  delay(2000);
  Serial.println(F("Ready."));
  pinMode(panicButton2, INPUT);
 
}

void loop()

{
  if (digitalRead(panicButton2) == HIGH && statusCheck == false)
  {
    if (sendEmail_2()) Serial.println(F("Email sent"));
    else Serial.println(F("Email failed"));
  }


}


byte sendEmail_2()
{
  byte thisByte = 0;
  byte respCode;

  if (client.connect(server, 25) == 1) {
    Serial.println(F("connected"));
  } else {
    Serial.println(F("connection failed"));
    return 0;
  }

  if (!eRcv()) return 0;
  Serial.println(F("Sending helo"));

  // change to your public ip
  client.println(F("helo 1.2.3.4"));

  if (!eRcv()) return 0;
  Serial.println(F("Sending From"));

  // change to your email address (sender)
  client.println(F("MAIL From: <MY@MAIL.COM>"));

  if (!eRcv()) return 0;

  // change to recipient address
  Serial.println(F("Sending To"));
  client.println(F("RCPT To: <YOU@MAIL.COM>"));

  if (!eRcv()) return 0;

  Serial.println(F("Sending DATA"));
  client.println(F("DATA"));

  if (!eRcv()) return 0;

  Serial.println(F("Sending email"));

  // change to recipient address
  client.println(F("To: YOU@MAIL.COM <YOU@MAIL.COM>"));

  // change to your address
  client.println(F("From: ALARM2 <>"));

  client.println(F("Subject: 2 email test buttom\r\n"));

  client.println(F("This is from my Arduino!"));

  client.println(F("."));

  if (!eRcv()) return 0;

  Serial.println(F("Sending QUIT"));
  client.println(F("QUIT"));

  if (!eRcv()) return 0;

  client.stop();

  Serial.println(F("disconnected"));

  return 1;
}



byte eRcv()
{
  byte respCode;
  byte thisByte;
  int loopCount = 0;

  while (!client.available()) {
    delay(1);
    loopCount++;

    // if nothing received for 10 seconds, timeout
    if (loopCount > 10000) {
      client.stop();
      Serial.println(F("\r\nTimeout"));
      return 0;
    }
  }

  respCode = client.peek();

  while (client.available())
  {
    thisByte = client.read();
    Serial.write(thisByte);
  }

  if (respCode >= '4')
  {
    efail();
    return 0;
  }

  return 1;
}


void efail()
{
  byte thisByte = 0;
  int loopCount = 0;

  client.println(F("QUIT"));

  while (!client.available()) {
    delay(1);
    loopCount++;

    // if nothing received for 10 seconds, timeout
    if (loopCount > 10000) {
      client.stop();
      Serial.println(F("\r\nTimeout"));
      return;
    }
  }

  while (client.available())
  {
    thisByte = client.read();
    Serial.write(thisByte);
  }

  client.stop();

  Serial.println(F("disconnected"));
}

Auduino Uno

/Michael

(deleted)

Could also add another variable such as emailSent

if(emailSent == 0 && digitalRead(panicButton2) == HIGH){
   sendemail();
   emailSent = 1;
}

Then reset emailSent to 0 when the alarm is reset. But as Spycatcher2k mentioned, state change might be the way to go. I've not had a need for state change yet. So, not 100% on how it works.

It is my first project.
I have looked at the State change detection example, but i can not se any solution.
Other suggestions?