Skip to content

Commit b75081e

Browse files
committed
Fixed an issue with smtp client (missing FQDN client name)
1 parent 3aa362f commit b75081e

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

smtpclient/SMTPClient.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,20 @@ bool SMTPClient::SendEmail()
126126
slist1 = curl_slist_append(slist1, (*itt).c_str());
127127
}
128128

129-
std::stringstream sstr;
129+
// Get the hostname from the server
130+
std::string hostname;
131+
char hn[256];
132+
if (gethostname(hn, sizeof(hn)) != SOCKET_ERROR) {
133+
hostname = hn;
134+
std::transform(hostname.begin(), hostname.end(), hostname.begin(), ::tolower);
135+
}
136+
else {
137+
// No hostname found, default to a fixed one
138+
hostname = "domoticz";
139+
}
130140

131-
sstr << "smtp://" << m_Server << ":" << m_Port << "/domoticz";
141+
std::stringstream sstr;
142+
sstr << "smtp://" << m_Server << ":" << m_Port << "/" << hostname;
132143
std::string szURL=sstr.str();//"smtp://"+MailServer+"/domoticz";
133144

134145
try

0 commit comments

Comments
 (0)