mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2026-05-13 09:35:51 +00:00
rename sendmail and add security list instead of checkbox
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user