Question:
I'm using the CkMailMan
object's VerifySmtpConnection
method to verify SMTP details. In a previous build of the Chilkat library (from about a year ago) this worked fine. With the latest version (downloaded last week), however, it is returning false
for exactly the same code. This is the lastErrorText after the failed response (a few details altered for privacy):
ChilkatLog:
VerifySmtpConnection:
DllDate: Dec 12 2012
UnlockPrefix: [...snipped...]
Username: NICK:Nick
Architecture: Little Endian; 32-bit
Language: Visual C++ 9.0
VerboseLogging: 1
Checking TCP/IP connectivity to the SMTP server.
This does not check the login/password.
AutoFix: SMTP port 25 is typically for unencrypted or explicit SSL/TLS.
To prevent auto-fix, set the AutoFix property = False/0
Checking connectivity to SMTP server [...snipped...]:25
smtp_host: [...snipped...]
smtp_port: 25
ConnectTimeoutMs_1: 30000
calling ConnectSocket2
IPV6 enabled connect with NO heartbeat.
connectingTo: [...snipped...]
resolveHostname1:
dnsCacheLookup: [...snipped...]
dnsCacheHit: [...snipped...]
--resolveHostname1
GetHostByNameHB_ipv4: Elapsed time: 0 millisec
myIP_1: 192.168.1.30
myPort_1: 2520
connect successful (1)
clientHelloMajorMinorVersion: 3.1
buildClientHello:
majorVersion: 3
minorVersion: 1
numRandomBytes: 32
sessionIdSize: 0
numCipherSuites: 10
numCompressionMethods: 1
--buildClientHello
readIncomingTls_serverHello:
readTlsRecord:
Timeout waiting to read socket or accept connection
timeoutMs: 30000
Failed to read TLS record (2)
tlsRec_msg: 91
msgLen: 8307
--readTlsRecord
--readIncomingTls_serverHello
Expected ServerHello but did not receive it.
Client handshake failed. (3)
Failed to connect to SMTP server.
--VerifySmtpConnection
Failed.
--ChilkatLog
From the previous, working, build of Chilkat libraries, this is the last error text after VerifySmtpConnection
succeeds:
ChilkatLog:
VerifySmtpConnection:
DllDate: Jan 6 2011
UnlockPrefix: [...snipped...]
Username: Nick
Component: Visual C++ 9.0
Checking TCP/IP connectivity to the SMTP server.
This does not check the login/password.
Checking connectivity to SMTP server [...snipped...]:25
smtp_host: [...snipped...]
smtp_port: 25
ConnectTimeoutMs: 30000
calling ConnectSocket2
Connect using IPV4.
Invalid protocol number
ai_protocol: 0
ipAddress: [...snipped...]
socketHandle: 0x3d4
ai_addrlen: 16
ai_addr: 0200 0019 3EAC AF8A 0000 0000 0000 0000
myIP_3: 192.168.1.30
myPort_3: 2454
connect successful.
ESMTP server [...snipped...]:25 is reachable
Success.
There's quite a lot different there. Where am I going wrong? I'm setting the SmtpHost
, SmptUsername
, SmtpPassword
, SmtpSsl
and SmtpLoginDomain
settings before calling VerifySmtpConnection
. I've tried with AutiFix set to true and false - same result.
To note, the Username
field in the lastErrorText is different from the previous build to the current build; current build shows my machine name prefixed to my username (NOT the domain name), whereas previous build only shows the username (no domain or machine prefix).
Also if it is of interest, the test for the current chilkat build takes about twice as long as the previous one (though that may be due to it failing somewhere...).
Thanks for any advice!
Notice this part of the LastErrorText:
AutoFix: SMTP port 25 is typically for unencrypted or explicit SSL/TLS. To prevent auto-fix, set the AutoFix property = False/0
What is it that you really need? Port 25 with no encryption? with implicit SSL? or with explicit (STARTTLS) SSL? w/ implicit SSL (i.e. SmtpSsl = true), the customary SMTP port is 465. When using port 25, you would expect either no SSL or explicit SSL. If the server is confusingly setup to do implicit SSL on port 25, make sure to set AutoFix = false.
After comparing the LastError of the failing and the succeeding calls, I think it has to do with the fact that a new SMTP connection needed to be established for the first call, but not for the second call.
These are the results:
Failing:
Succeeding: * VerifySMTPConnection:True ChilkatLog: VerifySmtpConnection: DllDate: Aug 30 2017 ChilkatVersion: 9.5.0.69 UnlockPrefix: GMXLIcMAILQ Architecture: Little Endian; 32-bit Language: .NET 4.6 VerboseLogging: 0 smtpConnectAndAuthenticate: smtpConnect: smtpHostname: smtp.gmail.com smtpPort: 465 connectionIsReady: Need new SMTP connection --connectionIsReady smtpSocketConnect:
Okay, there seems to be a bug in Chilkat in both the VB6 and the NET version:
ch.StartTLS has to be set to FALSE right from the start.
If not, it will only be set to FALSE automatically after the first call to VerifySMTPConnection, that's why it only works after the first call.