mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-05-13 01:25:52 +00:00
rename sendmail and add security list instead of checkbox
This commit is contained in:
@@ -134,8 +134,7 @@
|
||||
"modbus_timeout": 300,
|
||||
"developer_mode": true,
|
||||
"email_enabled": false,
|
||||
"email_ssl": false,
|
||||
"email_starttls": true,
|
||||
"email_security": 2,
|
||||
"email_server": "smtp.example.net",
|
||||
"email_port": 587,
|
||||
"email_login": "",
|
||||
|
||||
@@ -44,8 +44,7 @@ export interface Settings {
|
||||
modbus_max_clients: number;
|
||||
modbus_timeout: number;
|
||||
email_enabled: boolean;
|
||||
email_ssl?: boolean;
|
||||
email_starttls?: boolean;
|
||||
email_security:number;
|
||||
email_server: string;
|
||||
email_port: number;
|
||||
email_login: string;
|
||||
|
||||
@@ -165,10 +165,10 @@ const ApplicationSettings = () => {
|
||||
await doRestart();
|
||||
};
|
||||
|
||||
const sendemail = async () => {
|
||||
const sendmail = async () => {
|
||||
await sendAPI({
|
||||
device: 'system',
|
||||
cmd: 'sendemail',
|
||||
cmd: 'sendmail',
|
||||
data: 'Email notification test successful!',
|
||||
id: 0
|
||||
})
|
||||
@@ -403,42 +403,21 @@ const ApplicationSettings = () => {
|
||||
margin="normal"
|
||||
/>
|
||||
</Grid>
|
||||
<Grid
|
||||
size={4}
|
||||
sx={{ mt: !data.email_ssl && !data.email_starttls ? 0 : 3 }}
|
||||
>
|
||||
{!data.email_starttls && (
|
||||
<BlockFormControlLabel
|
||||
sx={{ width: '12ch' }}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.email_ssl}
|
||||
onChange={updateFormValue}
|
||||
name="email_ssl"
|
||||
disabled={
|
||||
data.email_starttls || data.email_ssl === undefined
|
||||
}
|
||||
/>
|
||||
}
|
||||
label="SSL/TLS"
|
||||
/>
|
||||
)}
|
||||
{!data.email_ssl && (
|
||||
<BlockFormControlLabel
|
||||
sx={{ width: '12ch' }}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={data.email_starttls}
|
||||
onChange={updateFormValue}
|
||||
name="email_starttls"
|
||||
disabled={
|
||||
data.email_ssl || data.email_starttls === undefined
|
||||
}
|
||||
/>
|
||||
}
|
||||
label="STARTTLS"
|
||||
/>
|
||||
)}
|
||||
<Grid>
|
||||
<TextField
|
||||
sx={{ width: '20ch' }}
|
||||
name="email_security"
|
||||
label={LL.SECURITY(0)}
|
||||
value={data.email_security}
|
||||
variant="outlined"
|
||||
onChange={updateFormValue}
|
||||
margin="normal"
|
||||
select
|
||||
>
|
||||
<MenuItem value={0}>{LL.OFF()}</MenuItem>
|
||||
<MenuItem value={1}>SSL</MenuItem>
|
||||
<MenuItem value={2}>StartTLS</MenuItem>
|
||||
</TextField>
|
||||
</Grid>
|
||||
</Grid>
|
||||
<Grid container spacing={2} rowSpacing={0}>
|
||||
@@ -505,7 +484,7 @@ const ApplicationSettings = () => {
|
||||
variant="outlined"
|
||||
color="primary"
|
||||
disabled={dirtyFlags.length !== 0}
|
||||
onClick={sendemail}
|
||||
onClick={sendmail}
|
||||
>
|
||||
Send test email
|
||||
</Button>
|
||||
|
||||
@@ -1336,4 +1336,4 @@ handshaked
|
||||
startm
|
||||
netifs
|
||||
testemail
|
||||
sendemail
|
||||
sendmail
|
||||
@@ -47,7 +47,7 @@ MAKE_WORD(raw)
|
||||
MAKE_WORD(watch)
|
||||
MAKE_WORD(syslog)
|
||||
MAKE_WORD(send)
|
||||
MAKE_WORD(sendemail)
|
||||
MAKE_WORD(sendmail)
|
||||
MAKE_WORD(telegram)
|
||||
MAKE_WORD(bus_id)
|
||||
MAKE_WORD(tx_mode)
|
||||
|
||||
@@ -65,7 +65,7 @@ MAKE_WORD_TRANSLATION(commands_cmd, "list all commands", "Liste aller Kommandos"
|
||||
MAKE_WORD_TRANSLATION(entities_cmd, "list all entities", "Liste aller Entitäten", "lijst van alle entiteiten", "lista all entiteter", "wyświetl wszsytkie encje", "Viser alle enheter", "lister toutes les entités", "Tüm varlıkları listele", "elenca tutte le entità", "zobraziť všetky entity", "vypsat všechny entity")
|
||||
MAKE_WORD_TRANSLATION(metrics_cmd, "list all prometheus metrics", "Liste aller Prometheus Metriken", "lijst van alle Prometheus metriken", "lista alla Prometheus metriker", "wyświetl wszystkie Prometheus metryki", "Viser alle Prometheus metrikker", "lister toutes les métriques Prometheus", "Tüm Prometheus metriklerini listele", "elenca tutte le metriche Prometheus", "zobraziť všetky Prometheus metriky", "vypsat všechny Prometheus metriky")
|
||||
MAKE_WORD_TRANSLATION(send_cmd, "send a telegram", "Sende EMS-Telegramm", "stuur een telegram", "skicka ett telegram", "wyślij telegram", "send et telegram", "envoyer un télégramme", "Bir telegram gönder", "invia un telegramma", "poslať telegram", "odeslat telegram")
|
||||
MAKE_WORD_TRANSLATION(sendemail_cmd, "send email", "Sende eMail", "stuur email", "skicka email", "wyślij email", "send e-post", "envoyer un email", "email gönder", "invia email", "poslať email", "odeslat email")
|
||||
MAKE_WORD_TRANSLATION(sendmail_cmd, "send email", "Sende eMail", "stuur email", "skicka email", "wyślij email", "send e-post", "envoyer un email", "email gönder", "invia email", "poslať email", "odeslat email")
|
||||
MAKE_WORD_TRANSLATION(read_cmd, "send read request", "Sende Leseanfrage", "stuur leesaanvraag", "skicka en läsförfrågan", "wyślij żądanie odczytu", "send leseforespørsel", "envoyer une demande de lecture", "okuma isteği gönder", "invia richiesta di lettura", "odoslať žiadosť o prečítanie", "odeslat požadavek na čtení")
|
||||
MAKE_WORD_TRANSLATION(setiovalue_cmd, "set I/O value", "Setze Werte E/A", "instellen standaardwaarde", "sätt ett I/O-värde", "ustaw wartość", "sett en io verdi", "définir valeur E/S", "Giriş/Çıkış değerlerini ayarla", "imposta valore io", "nastaviť hodnotu io", "nastavit hodnotu I/O")
|
||||
MAKE_WORD_TRANSLATION(changeloglevel_cmd, "change log level", "Ändere Protokollebene", "aanpassen log niveau", "ändra logg-nivå", "zmień poziom log-u", "endre loggnivå", "changer le niveau de journal", "Kayıt seviyesini değiştir", "cambia livello registrazione", "zmeniť úroveň protokolu", "změnit úroveň protokolování")
|
||||
|
||||
@@ -116,15 +116,14 @@ bool System::command_send(const char * value, const int8_t id) {
|
||||
}
|
||||
|
||||
// send email via SMTP
|
||||
bool System::command_sendemail(const char * value, const int8_t id) {
|
||||
bool System::command_sendmail(const char * value, const int8_t id) {
|
||||
bool enabled = false;
|
||||
bool ssl, starttls;
|
||||
uint8_t security;
|
||||
uint16_t port;
|
||||
String server, login, pass, sender, recp, subject;
|
||||
EMSESP::webSettingsService.read([&](WebSettings & settings) {
|
||||
enabled = settings.email_enabled;
|
||||
ssl = settings.email_ssl;
|
||||
starttls = settings.email_starttls;
|
||||
security = settings.email_security;
|
||||
server = settings.email_server;
|
||||
port = settings.email_port;
|
||||
login = settings.email_login;
|
||||
@@ -136,8 +135,13 @@ bool System::command_sendemail(const char * value, const int8_t id) {
|
||||
if (!enabled) {
|
||||
return false;
|
||||
}
|
||||
LOG_DEBUG("Command sendemail port %d%s called with '%s'", port, ssl ? " (SSL)" : starttls ? " (STARTTLS)" : "", value);
|
||||
// LOG_DEBUG("Command sendemail port %d called with '%s'", port, value);
|
||||
LOG_DEBUG("Command sendmail port %d%s called with '%s'",
|
||||
port,
|
||||
security == EMAIL_SECURITY::SSL ? " (SSL)"
|
||||
: security == EMAIL_SECURITY::STARTTLS ? ""
|
||||
: " (STARTTLS)",
|
||||
value);
|
||||
|
||||
bool success = false;
|
||||
|
||||
#ifndef NO_TLS_SUPPORT
|
||||
@@ -149,9 +153,13 @@ bool System::command_sendemail(const char * value, const int8_t id) {
|
||||
ssl_client->setClient(basic_client);
|
||||
ssl_client->setInsecure();
|
||||
ssl_client->setBufferSizes(1024, 1024);
|
||||
r_client->addPort(port, starttls ? readymail_protocol_tls : ssl ? readymail_protocol_ssl : readymail_protocol_plain_text);
|
||||
r_client->addPort(port,
|
||||
security == EMAIL_SECURITY::NONE ? readymail_protocol_plain_text
|
||||
: security == EMAIL_SECURITY::SSL ? readymail_protocol_ssl
|
||||
: readymail_protocol_tls);
|
||||
|
||||
// smtp->connect(server, port, sendemailCallback);
|
||||
|
||||
// smtp->connect(server, port, sendmailCallback);
|
||||
smtp->connect(server, port);
|
||||
if (!smtp->isConnected()) {
|
||||
LOG_ERROR("send email connection error");
|
||||
@@ -1086,7 +1094,7 @@ void System::commands_init() {
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(read), System::command_read, FL_(read_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(send), System::command_send, FL_(send_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, FL_(fetch_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(sendemail), System::command_sendemail, FL_(sendemail_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(sendmail), System::command_sendmail, FL_(sendmail_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(format), System::command_format, FL_(format_cmd), CommandFlag::ADMIN_ONLY);
|
||||
Command::add(EMSdevice::DeviceType::SYSTEM, F_(txpause), System::command_txpause, FL_(txpause_cmd), CommandFlag::ADMIN_ONLY);
|
||||
|
||||
@@ -72,6 +72,7 @@ enum SYSTEM_STATUS : uint8_t {
|
||||
|
||||
enum FUSE_VALUE : uint8_t { ALL = 0, MFG = 1, MODEL = 2, BOARD = 3, REV = 4, BATCH = 5, FUSE = 6 };
|
||||
|
||||
enum EMAIL_SECURITY : uint8_t { NONE = 0, SSL = 1, STARTTLS = 2 };
|
||||
struct PartitionInfo {
|
||||
std::string version;
|
||||
size_t size;
|
||||
@@ -95,7 +96,7 @@ class System {
|
||||
static bool command_info(const char * value, const int8_t id, JsonObject output);
|
||||
static bool command_response(const char * value, const int8_t id, JsonObject output);
|
||||
static bool command_service(const char * cmd, const char * value);
|
||||
static bool command_sendemail(const char * value, const int8_t id);
|
||||
static bool command_sendmail(const char * value, const int8_t id);
|
||||
static bool command_txpause(const char * value, const int8_t id);
|
||||
|
||||
static bool get_value_info(JsonObject root, const char * cmd);
|
||||
|
||||
@@ -88,8 +88,7 @@ void WebSettings::read(WebSettings & settings, JsonObject root) {
|
||||
#else
|
||||
root["email_enabled"] = false;
|
||||
#endif
|
||||
root["email_ssl"] = settings.email_ssl;
|
||||
root["email_starttls"] = settings.email_starttls;
|
||||
root["email_security"] = settings.email_security;
|
||||
root["email_server"] = settings.email_server;
|
||||
root["email_port"] = settings.email_port;
|
||||
root["email_login"] = settings.email_login;
|
||||
@@ -315,8 +314,7 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
||||
settings.weblog_compact = root["weblog_compact"] | EMSESP_DEFAULT_WEBLOG_COMPACT;
|
||||
|
||||
settings.email_enabled = root["email_enabled"] | FACTORY_EMAIL_ENABLE;
|
||||
settings.email_ssl = root["email_ssl"] | FACTORY_EMAIL_SSL;
|
||||
settings.email_starttls = root["email_starttls"] | FACTORY_EMAIL_STARTTLS;
|
||||
settings.email_security = root["email_security"] | FACTORY_EMAIL_SECURITY;
|
||||
settings.email_server = root["email_server"] | FACTORY_EMAIL_SERVER;
|
||||
settings.email_port = root["email_port"] | FACTORY_EMAIL_PORT;
|
||||
settings.email_login = root["email_login"] | FACTORY_EMAIL_LOGIN;
|
||||
@@ -325,9 +323,6 @@ StateUpdateResult WebSettings::update(JsonObject root, WebSettings & settings) {
|
||||
settings.email_recp = root["email_recp"] | FACTORY_EMAIL_TO;
|
||||
settings.email_subject = root["email_subject"] | FACTORY_EMAIL_SUBJECT;
|
||||
|
||||
if (settings.email_ssl && settings.email_starttls) {
|
||||
settings.email_ssl = false;
|
||||
}
|
||||
// if no psram limit weblog buffer to 25 messages
|
||||
if (EMSESP::system_.PSram() > 0) {
|
||||
settings.weblog_buffer = root["weblog_buffer"] | EMSESP_DEFAULT_WEBLOG_BUFFER;
|
||||
|
||||
@@ -29,11 +29,8 @@
|
||||
#ifndef FACTORY_EMAIL_ENABLE
|
||||
#define FACTORY_EMAIL_ENABLE false
|
||||
#endif
|
||||
#ifndef FACTORY_EMAIL_SSL
|
||||
#define FACTORY_EMAIL_SSL false
|
||||
#endif
|
||||
#ifndef FACTORY_EMAIL_STARTTLS
|
||||
#define FACTORY_EMAIL_STARTTLS true
|
||||
#ifndef FACTORY_EMAIL_SECURITY
|
||||
#define FACTORY_EMAIL_SECURITY 2
|
||||
#endif
|
||||
#ifndef FACTORY_EMAIL_PORT
|
||||
#define FACTORY_EMAIL_PORT 587
|
||||
@@ -108,8 +105,7 @@ class WebSettings {
|
||||
uint8_t modbus_max_clients;
|
||||
uint32_t modbus_timeout;
|
||||
bool email_enabled;
|
||||
bool email_ssl;
|
||||
bool email_starttls;
|
||||
uint8_t email_security;
|
||||
String email_server;
|
||||
uint16_t email_port;
|
||||
String email_login;
|
||||
|
||||
@@ -132,8 +132,7 @@
|
||||
"modbus_timeout": 300,
|
||||
"developer_mode": true,
|
||||
"email_enabled": false,
|
||||
"email_ssl": false,
|
||||
"email_starttls": true,
|
||||
"email_security": 2,
|
||||
"email_server": "smtp.example.net",
|
||||
"email_port": 587,
|
||||
"email_login": "",
|
||||
|
||||
Reference in New Issue
Block a user