Try this:
void loop()
{
static bool DoorIsClosed=true; // Let's assume it's closed for starting
static bool SMSSent=false; // Tells us whether we've sent an SMS for the latest instance of the door being open
currDoorState = digitalRead(doorContactPin);
if(currDoorState != prevDoorState) // Door was closed and is now open or door was open and is now closed
{
if(currDoorState == LOW)
{
// Door is now closed
DoorIsClosed=true;
}
else
{
// Door is now open
DoorIsClosed=false;
doorOpenTime = millis();
}
SMSSent=false; // Door state changed, we may have a new opportunity to send SMS
}
prevDoorState = currDoorState;
// Now see if the door is open
if(!DoorIsClosed)
{
if(millis() - doorOpenTime >= time_threshold)
{
sendSMS();
SMSSent=true;
}
}
}
Not tested, not even compiled.