smtp problem

I am trying to modify smtp.c to send an email message each time an input is detected on a 3700 module. The first email gets sent but after that there is an error opening port when I try to send a second email. When I turn on SMTP_VERBOSE it says that the connection is closing after the first email is sent. It is my understanding that the sock must close before it can be used again so I’m not sure what the problem is.

Are you doing something like this after sending the message: