Sunday, November 19, 2006

Sample usage of fetchmail with gmail

You can configure fetchmail to access your @gmail account using pop protocol and to forward the emails to another email address.

To access your @gmail account using pop protocol, first, you have to enable pop support in gmail.
Follow this link if pop access is disabled in your @gmail account:
http://www.google.com/search?q=how+to+enable+pop+in+gmail

From the shell type (Don't include $:)
$: fetchmail -p POP3 -k -v -a --ssl -P 995 --smtpname xxx@xxx.xxx -u xxx@gmail.com pop.gmail.com

It will ask your password. Type your password and your emails will be forwarded to xxx@xxx.xxx address.

Parameter descriptions:
--ssl Gmail needs ssl connection to their mail server.
-P 996 Default pop3 port is 110. Gmail is using different port number and you have to define that port number. Remark: this is capital p.
-p POP3 Specify the protocol to use
-k Keep retrieved messages on the remote server mailserver.
-v Verbose mode. This writes the detailed output of the fetchmail to standard output.
-a Retreive both old and new messages from the mail server.
xxx@xxx.com Email address that emails will be forwarded
xxx@gmail.com Your gmail account.

Output should be like this:

Enter password for [xxx@gmail.com@pop.gmail.com]:
fetchmail: 6.2.5 querying pop.gmail.com (protocol POP3) at Fri 17 Nov 2006 05:03:00 PM PST: poll started
fetchmail: Issuer Organization: Equifax
fetchmail: Unknown Issuer CommonName
fetchmail: Server CommonName: pop.gmail.com
fetchmail: pop.gmail.com key fingerprint: 59:51:61:89:AB:DD:B2:35:94:BB:44:97:A0:39:D5:B4
fetchmail: Warning: server certificate verification: unable to get local issuer certificate
fetchmail: Issuer Organization: Equifax
fetchmail: Unknown Issuer CommonName
fetchmail: Server CommonName: pop.gmail.com
fetchmail: Warning: server certificate verification: certificate not trusted
fetchmail: Issuer Organization: Equifax
fetchmail: Unknown Issuer CommonName
fetchmail: Server CommonName: pop.gmail.com
fetchmail: Warning: server certificate verification: unable to verify the first certificate
fetchmail: POP3< +OK Gpop ready for requests from [XXX.XXX.XXX.XXX] 55pf8639445ugq fetchmail: POP3> CAPA
fetchmail: POP3< +OK Capability list follows fetchmail: POP3<> USER [xxx@gmail.com]
fetchmail: POP3< +OK send PASS fetchmail: POP3> PASS *
fetchmail: POP3< +OK Welcome. fetchmail: POP3> STAT
fetchmail: POP3< +OK 0 0 fetchmail: No mail for [xxx@gmail.com] at pop.gmail.com fetchmail: POP3> QUIT
fetchmail: POP3< +OK Farewell.
fetchmail: 6.2.5 querying pop.gmail.com (protocol POP3) at Fri 17 Nov 2006 05:03:05 PM PST: poll completed
fetchmail: normal termination, status 1