SMTP Timeout Sending Large Email
Question:
While trying to send an email with an attachment of size 9MB from my application, I get an error. Interestingly, the file gets delivered to the email address still we get the error in the application.
Answer:
Looking at the MailMan.LastErrorText for the call to SendEmail, we can see this:
ChilkatLog: SendEmail: ... ReadTimeout: 30000 ... ... sendCmdToSmtp: SmtpCmdSent: DATA<CRLF> --sendCmdToSmtp ... ... sendCmdToSmtp: SmtpCmdSent: <CRLF>.<CRLF> --sendCmdToSmtp readSmtpResponse: Failed to read beginning of SSL/TLS record. b: 0 dbSize: 0 nReadNBytes: 0 idleTimeoutMs: 30000 readTlsRecord: Socket operation timeout. ... tlsApp: Socket operation timeout. elapsedMs: Elapsed time: 30953 millisec idleTimeoutMs: 30000 --readSmtpResponse ....
Notice that the MailMan.ReadTimeout property is set to the default of 30 seconds (i.e. 30000 milliseconds).
Also, the MIME content of the email, including the 9MB attachment was sent in the DATA command. Then the terminating “<CRLF>.<CRLF>” was sent, and then finally Chilkat waits for the response from the mail server (i.e. for the mail server to consume and process the email). However, it takes longer than 30 seconds for the mail server to process such a large email. After 30 seconds, Chilkat stops waiting for the response because of the MailMan.ReadTimeout property setting. The email is still delivered because even though Chilkat stopped waiting for the response, the mail server was happily continuing with the processing/sending of the email. Eventually, the mail server (on its end) sent the email and then likely tried to respond to Chilkat (the SMTP client), which was no longer waiting for the response. Thus, the mail was successfully sent, but the SendEmail method returns a failed status.
The solution is to increase the value of the MailMan.ReadTimeout to acccommodate the potential long delay in response time when sending large emails.
Perhaps increase the MailMan.ReadTimeout to 60 seconds, or 120 seconds.