How to access GMail SMTP/POP3 service with stunnel



Access GMail SMTP/POP3 services with stunnel

Google's Gmail SMTP/POP3 access is free for all Gmail users and could be accessed only via SSL. Note that this service is disabled by default and could be enabled by following these instructions.

This post shows the way how to access directly POP3/SMTP Gmail services with stunnel which is installed by default on most Linux distributions. Stunnel is designed to work as SSL encryption wrapper between remote clients and local or remote servers.


To have the direct access to GMail SMTP/POP3 service follow 2 simple steps:

1) Alter the stunnel config /etc/stunnel/stunnel.conf and fit it with following contents:

cert = /etc/stunnel/stunnel.pem
debug = 7
output = /var/log/stunnel.log
client = yes

[pop3s]
accept = 127.0.0.1:11110
connect = pop.gmail.com:995

[smtps]
accept = 127.0.0.1:11025
connect = smtp.gmail.com:465

The above config will make stunnel to listen at port 11110 for incoming POP3 connections and will redirect them to GMail via SSL port 995 (pop3s). Also, for SMTP connections, the stunnel will listen at port 11025 and will redirect all requests them to GMail via SSL port 465 (smtps).

Note: If you are unable to create your stunnel.pem file you can use the following form to generate this file for you.

2) Launch stunnel and check the connection to the GMail server:

stunnel
netstat -nalp|grep stunnel
telnet localhost 11110
telnet localhost 11025

You should get the same output like is shown in above screenshot.