Trying to use the telnet capability to attach to a local smtp server. While not the most secure thing the idea is to be able to bypass an external RESTful server like my other driver in order to send email messages.
The issue is I can connect to the server but cannot send any messages. Tried playing around with various parameters (terminate chars CR,LF,CR\LF, terminal type) as well as embedding "\n" & "\r\n"'s in the message strings but no go. I CAN connect, authorize (plain) and send an email via the command line telnet utility in Linux so thought I should be able to do it in HE.
Here are the related code snippets.. this is the connection (which works) - I left the commented out attempts in just to show some of my testing:
logDebug("Connecting to ${EmailServer}:${EmailPort}")
telnetClose()
//telnetConnect([terminalType: 'VT100',termChars:[13,10]],EmailServer,
EmailPort.toInteger(), null, null)
//telnetConnect([termChars:[10]],EmailServer, EmailPort.toInteger(), null, null)
//telnetConnect([termChars:[13]],EmailServer, EmailPort.toInteger(), null, null)
telnetConnect(EmailServer, EmailPort.toInteger(), null, null)
And here is the parse function.. I am embedding some sendMsgs which may or may not be a good idea but I need to sequence things as the messages appear...
def parse(String msg) {
logDebug("parse ${msg}")
if (msg.startsWith("220")) {
logDebug("Connected!")
sendMsg("ehlo ${EmailDomain}")
}
if (msg.startsWith("250")) {
logDebug("Domain Configured!")
}
if ( msg != state.lastMsg){
logDebug("setting state.lastMsg to ${msg}")
state.lastMsg = "${msg}"
}
sendEvent([name: "telnet", value: "${msg}"])
}
Here is the sendMsg function..
def sendMsg(String msg) {
logDebug("Sending ${msg}")
return new hubitat.device.HubAction("${msg}", hubitat.device.Protocol.TELNET)
}