Automatic Email Sending using Gmail

Free service from Gmail is great.  Gmail open up its SMTP server and allow program to connect to their SMTP server to send automated email.

Google does not accept ordinary SMTP traffic as it is not encrypted and prone to sniffing of the username and password.  Therefore, we cannot connect to Google SMTP server directly using SMTP command, such as Blat Mail.  We need to build a secure channel.

We use stunnel to create the encrypted tunnel.  The BLAT mail then connects to localhost:10025 which stunnel is listening.  stunnel receives the request from BLAT, encrypts the traffic and relay it to smtp.gmail.com:465.  For the return traffic from gmail, stunnel will do the decryption vice versa.


You may also refer to this site for a description of stunnel installation.

stunnel.conf
;Gmail
[ssmtp]
accept  = 127.0.0.1:10025
connect = smtp.gmail.com:465

;[hotmailsmtp]
;accept = 127.0.0.1:10026
;connect = smtp.live.com:465


Windows Batch file to send SMTP email
D:\BLATMAIL\blat.exe -to reipient@domain.com.hk -f YourAccount@gmail.com -server 127.0.0.1 -u YourAccount@gmail.com -pw YourPassword -subject "Email Test" -body "Email Test. This is a test email"

Comments

Popular Posts