[SOLVED] Code send email randomly

Hi
I would need some help to get working the attached code
It receives a string representing a sensor reading sent from an external mcu to Photon.
If the code running on external mcu detects that some threshold value is exceeded, the external mcu sent a hex value to the Photon’s code so that Photon send an Email.
But it only happens some times immediately after a code was flashed.

// This #include statement was automatically added by the Particle IDE.
#include <blynk.h>

// This #include statement was automatically added by the Particle IDE.


/*************************************************************
                                

  Blynk library is licensed under MIT license
  This example code is in public domain.

 *************************************************************



  App project setup:
    Value Display widget attached to V7
 *************************************************************/

/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial1


//#include <blynk.h>



// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "xxxxxxxxxxxxxxxxxxxxxdebe15bca715xxxx";

char Ampstr[6];
BlynkTimer timer;
 int Email_1 =0;
int AlreadySent=0;


void sendAmp()
{
 
  
 int i=0;


while ( Serial1.available() && i < 6  )
  
      {  
     
     
      Ampstr[i] = Serial1.read(); 
      if(  Ampstr[i]=='\0'   )
         { break;}
          i++;
     
      }
 
     i=0;
     Ampstr[5] = '\0'; 
    // Send it to the server
  Blynk.virtualWrite(V7, Ampstr);
 
  
} 

  
  

void SEmail()
{
   

 
   while ( Serial1.available()>0) 
   {
       Email_1= Serial1.read(); 
       if ( Email_1)
        { Blynk.email("Email address ", "High Amps limit reached", "Amps >7.0");
          Email_1=0; break;}
            
            
           
   }
     
     
  }



void setup()
{
 
  // Debug console
  Serial1.begin(56700);

  delay(5000); // Allow board to settle
  Blynk.begin(auth);

   timer.setInterval(1000L, sendAmp);
  timer.setInterval(20000L, SEmail);
 
}



void loop()
{
  Blynk.run();
  timer.run();

}

Thanks for some help

There are limitations imposed on the email… Only 1 email per 15 seconds is allowed, etc. http://docs.blynk.cc/#widgets-notifications-email

You may have exceeded one of those limits shortly after bootup.

@Gunner
Thank you I’’ take care of that.