How to setup stunnel so that gmail can use my own smtp server to send messages.
- by igorhvr
I am trying to setup gmail to send messages using my own smtp server.
I am doing this by using stunnel over a non-ssl enabled server. I am able to use my own smtp client with ssl enabled just fine to my server.
Unfortunately, however, gmail seems to be unable to connect to my stunnel port.
Gmail seems to be simply closing the connection right after it is established - I get a "SSL socket closed on SSL_read" on my server logs.
On gmail, I get a "We are having trouble authenticating with your other mail service. Please try changing your SSL settings. If you continue to experience difficulties, please contact your other email provider for further instructions." message.
Any help / tips on figuring this out will be appreciated. My certificate is self-signed - could this perhaps be related to the problem I am experiencing?
I pasted the entire SSL session (logs from my server) below.
2011.01.02 16:56:20 LOG7[20897:3082491584]: Service ssmtp accepted FD=0 from 209.85.210.171:46858
2011.01.02 16:56:20 LOG7[20897:3082267504]: Service ssmtp started
2011.01.02 16:56:20 LOG7[20897:3082267504]: FD=0 in non-blocking mode
2011.01.02 16:56:20 LOG7[20897:3082267504]: Option TCP_NODELAY set on local socket
2011.01.02 16:56:20 LOG7[20897:3082267504]: Waiting for a libwrap process
2011.01.02 16:56:20 LOG7[20897:3082267504]: Acquired libwrap process #0
2011.01.02 16:56:20 LOG7[20897:3082267504]: Releasing libwrap process #0
2011.01.02 16:56:20 LOG7[20897:3082267504]: Released libwrap process #0
2011.01.02 16:56:20 LOG7[20897:3082267504]: Service ssmtp permitted by libwrap from 209.85.210.171:46858
2011.01.02 16:56:20 LOG5[20897:3082267504]: Service ssmtp accepted connection from 209.85.210.171:46858
2011.01.02 16:56:20 LOG7[20897:3082267504]: FD=1 in non-blocking mode
2011.01.02 16:56:20 LOG6[20897:3082267504]: connect_blocking: connecting 127.0.0.1:25
2011.01.02 16:56:20 LOG7[20897:3082267504]: connect_blocking: s_poll_wait 127.0.0.1:25: waiting 10 seconds
2011.01.02 16:56:20 LOG5[20897:3082267504]: connect_blocking: connected 127.0.0.1:25
2011.01.02 16:56:20 LOG5[20897:3082267504]: Service ssmtp connected remote server from 127.0.0.1:3701
2011.01.02 16:56:20 LOG7[20897:3082267504]: Remote FD=1 initialized
2011.01.02 16:56:20 LOG7[20897:3082267504]: Option TCP_NODELAY set on remote socket
2011.01.02 16:56:20 LOG5[20897:3082267504]: Negotiations for smtp (server side) started
2011.01.02 16:56:20 LOG7[20897:3082267504]: RFC 2487 not detected
2011.01.02 16:56:20 LOG5[20897:3082267504]: Protocol negotiations succeeded
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): before/accept initialization
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read client hello A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write server hello A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write certificate A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write certificate request A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 flush data
2011.01.02 16:56:20 LOG5[20897:3082267504]: CRL: verification passed
2011.01.02 16:56:20 LOG5[20897:3082267504]: VERIFY OK: depth=2, /C=US/O=Equifax/OU=Equifax Secure Certificate Authority
2011.01.02 16:56:20 LOG5[20897:3082267504]: CRL: verification passed
2011.01.02 16:56:20 LOG5[20897:3082267504]: VERIFY OK: depth=1, /C=US/O=Google Inc/CN=Google Internet Authority
2011.01.02 16:56:20 LOG5[20897:3082267504]: CRL: verification passed
2011.01.02 16:56:20 LOG5[20897:3082267504]: VERIFY OK: depth=0, /C=US/ST=California/L=Mountain View/O=Google Inc/CN=smtp.gmail.com
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read client certificate A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read client key exchange A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read certificate verify A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 read finished A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write change cipher spec A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 write finished A
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL state (accept): SSLv3 flush data
2011.01.02 16:56:20 LOG7[20897:3082267504]: 1 items in the session cache
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 client connects (SSL_connect())
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 client connects that finished
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 client renegotiations requested
2011.01.02 16:56:20 LOG7[20897:3082267504]: 1 server connects (SSL_accept())
2011.01.02 16:56:20 LOG7[20897:3082267504]: 1 server connects that finished
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 server renegotiations requested
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 session cache hits
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 external session cache hits
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 session cache misses
2011.01.02 16:56:20 LOG7[20897:3082267504]: 0 session cache timeouts
2011.01.02 16:56:20 LOG6[20897:3082267504]: SSL accepted: new session negotiated
2011.01.02 16:56:20 LOG6[20897:3082267504]: Negotiated ciphers: RC4-MD5 SSLv3 Kx=RSA Au=RSA Enc=RC4(128) Mac=MD5
2011.01.02 16:56:20 LOG7[20897:3082267504]: SSL socket closed on SSL_read
2011.01.02 16:56:20 LOG7[20897:3082267504]: Socket write shutdown
2011.01.02 16:56:20 LOG5[20897:3082267504]: Connection closed: 167 bytes sent to SSL, 37 bytes sent to socket
2011.01.02 16:56:20 LOG7[20897:3082267504]: Service ssmtp finished (0 left)