Sending mail with Gmail account too many

When openhab works on win7 is no problem to send one message when the item is on. But when openhab work on raspberry pi is when I press the button for one second to send 10 e-mail. And when a button is pressed 1 minute to have 100 email.

openhab.cfg

######################## Mail Action configuration ####################################

The SMTP server hostname, e.g. “smtp.gmail.com

mail:hostname=smtp.gmail.com

the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS))

mail:port=587

the username and password if the SMTP server requires authentication

mail:username=email
mail:password=mypassword

The email address to use for sending mails

mail:from=email@gmail.com

set to “true”, if TLS should be used for the connection

(optional, defaults to false)

mail:tls=true

set to “true”, if POP before SMTP (another authentication mechanism)

should be enabled. Username and Password are taken from the above

configuration (optional, default to false)

#mail:popbeforesmtp=

Character set used to encode message body

(optional, if not provided platform default is used)

#mail:charset=

Rules.

rule “Napad”
when
Item Light_GF_Spizarka received update ON
then

    // send an email
    sendMail("email@gmail.com", "Napad!!", "Call!!!")

end

Firstly, I would suggest to post code as code :wink: as it’s a bit unreadable in your posting. Code within text can be marked with one Backtick (`) before and after and will show up like the word Backtick. For more lines of code, you can use 4 spaces in front of every line or (simpler) use 3 Backticks before and after code. these Backticks have to have it’s own line, no other Characters or space allowed.

################## Mail Action configuration

# The SMTP server hostname, e.g. "smtp.gmail.com"
mail:hostname=smtp.gmail.com

# the SMTP port to use (optional, defaults to 25 (resp. 587 for TLS))
mail:port=587

# the username and password if the SMTP server requires authentication
mail:username=email
mail:password=mypassword

# The email address to use for sending mails
mail:from=email@gmail.com

# set to "true", if TLS should be used for the connection
# (optional, defaults to false)
mail:tls=true

# set to "true", if POP before SMTP (another authentication mechanism)
# should be enabled. Username and Password are taken from the above
# configuration (optional, default to false)
# mail:popbeforesmtp=

# Character set used to encode message body
# (optional, if not provided platform default is used)
# mail:charset=

As you can see, it’s way more readable.

Now to your specific problem:
I can only guess why the behavior under windows is different to linux, but to be true, the linux behavior is, what I would have expected, as you are using the received update ON trigger. openHAB doesn’t differ between long and short press (at least for simple switches), so it would update the Item as long as you’re pressing the button.
Try changed to ON for trigger, this would only fire one time per switching, no matter how long you are pressing the button.

All loggings can be found at ./logs/openhab.log and ./logs/events.log, so there is no need to hardcopy your screen :wink:

Thank you for your attention, I improved
I changed ON the trigger and also when push 1 second I also have a 10x email sometimes 6x email

Are you sure your Rule looks like

rule "Napad"
when
    Item Light_GF_Spizarka changed to ON
then
    // send an email
    sendMail("email@gmail.com", "Napad!!", "Call!!!")
end

?

Yes
14 kwi 2016 18:18 “Udo Hartmann” bot@community.openhab.org napisał(a):

What kind of Button do you use?

And what is the definition of Light_GF_Spizarka in .items ?

Items

Switch Light_GF_Spizarka “Light” (GF_Spizarka, Lights) {modbus=“slave1:7”}

I use “normal” switch.
I also tried with this button and it is the same: .

Sitemap:
Switch item=Light_GF_Spizarka label=“swiatlo” mappings=[ON=“On”,OFF=“Off”]

When button is ON all the time sends email(per 1 sec 6x) . I depend, when button is ON send one email about the status change

Only what I see now in win7 is version org.openhab.action.mail-1.8.0 but on raspberry pi is version org.openhab.action.mail-1.8.1. This is different ??

I returned it to version 1.8.0 on raspberry pi and nothing has changed . Also send a lot of emails . Has anyone have any idea?