4 Replies Latest reply on Aug 9, 2016 10:52 AM by gsee RSS
    gsee Apprentice

    Alert subscription stopped sending emails

    Hi,

     

    I have a subscription to an alert that has stopped sending emails. The subscription to AnyAlert is enabled on a Thing Template, and the alerts are enabled on the appropriate Things. The subscription code is:

     

    sensorMessage = eventData.description + " at Sensor " + me.SensorID;
    linkMessage = "You can view the status of all sensors locations here."
    var params = {
        cc: "username@gmail.com",
        subject: me.SensorName + " alert" /* STRING */,
        from: "username@company.com" /* STRING */,
        to: me.ThingManager.smsAddress,
        body: "At "+ eventTime + " " + sensorMessage + "<br>" + linkMessage,
    };
    
    Things["PasswordMailServer"].SendMessage(params);
    
    
    
    

     

    The alerts were sending emails correctly a week ago. I acknowledged a few of the alerts in the monitor, but not all, and added several new alerts that are still not sending emails, although I can see the new alerts in the Alert Summary.

     

    I'd appreciate any help!

    Thanks

      • Re: Alert subscription stopped sending emails
        ewertonm Creator

        Hi Gloria,

         

        Do you see any error in the logger (Monitoring->Logs->Script) ?

         

        What would  do is to add a logger.warn("Executed"); statement in the code just to figure out if the service is running and it is not the Mail Server that is holding the message from being sent (if you haven't done it yet)

         

        Cheers

        Ewerton

          • Re: Alert subscription stopped sending emails
            gsee Apprentice

            Thanks Ewerton. That narrowed it down a lot.

            I added a couple logger statements, and it turns out the me.ThingManager.smsAddress is coming back undefined. Any suggestions on how to pull the sms or email for a user defined as a property of each Thing? I can get it to work for a hardcoded email or sms address (or hard coded user) but that's not scalable to multiple users.

              • Re: Alert subscription stopped sending emails
                ewertonm Creator

                I think you could use the GetPropertyValues from the User Object once you retrieve the user name. Maybe it is not the elegant way to do it, but I did it and it did the trick:

                 

                var userProperties = Users[me.user].GetPropertyValues();

                 

                logger.warn(userProperties.emailAddress);

                logger.warn(userProperties.smsAddress);

                 

                Where me.user is a variable of the type USERNAME that I used to select an user.

                 

                Not sure if this is your exact use case tough.

                 

                 

                ***UPDATED***

                 

                Actually you don't even need the Get Property Values call. Just make it an indirect reference:

                 

                logger.warn(Users[me.user].emailAddress);

                logger.warn(Users[me.user].smsAddress);

                 

                Cheers

                Ewerton