I would recommend looking at the Oscat Network library. It's on the store for free. There is an official SMPT package called Mail Service
The Oscat Forum is here. Both German and English are accepted but you can only change the language if you have an account. In either case if you want to read it in English you'll have to run most of it through a translator since posts don't get translated and most of it is in German.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
hello, can you send me email from raspberry pi, when a bool is activated.
I would recommend looking at the Oscat Network library. It's on the store for free. There is an official SMPT package called Mail Service
The Oscat Forum is here. Both German and English are accepted but you can only change the language if you have an account. In either case if you want to read it in English you'll have to run most of it through a translator since posts don't get translated and most of it is in German.
Another way: install cURL to Raspberry, use it from CODESYS IEC-code through SysProcess library.
https://ec.haxx.se/usingcurl/usingcurl-smtp m