ARTICLE

Gmail on your linux box
Contributed by Girish Venkatachalam in Misc on 2007-05-16 15:04:18
Wouldn't it be nice if you can use the power of gmail on your locallinux box? Especially since typing an e-mail is always much fun withyour favourite editor compared to the boring web interface.

Nowadays most people have a gmail address. Its spam control mechanism is marvellous, has a slick interface and of course provides plenty of storage space.

Wouldn't it be nice if you can use the power of gmail on your local linux box? Especially since typing an e-mail is always much fun with your favourite editor compared to the boring web interface.

It can take some effort so set this up but it offers plenty of possibilities once you get it working.

First of all you need to download the mails from the gmail server to your linux box. You could do it using POP3 or IMAP4. But gmail unfortunately supports only the old POP3 protocol. So we don't have a choice.

You could use fetchmail but it is very hard to get it working with gmail. Moreover when you have a much better alternative why stick to old ones. Like sticking to yahoo! mail even after you have gmail.

Anyway getmail is a python program and is really cool. It is easily installed and configuring it is a charm especially with gmail sine it uses SSL and getmail takes of all the details for you.

My getmailrc file looks like this.

[retriever]
type = SimplePOP3SSLRetriever
server = pop.gmail.com
username = foo
password = bar

[destination]
# this can be changed to Maildir, etc. RTFM.
type = MDA_external
path = /usr/bin/procmail
unixfrom = True

#type = Mboxrd
#path = ~/.getmail/inbox

[options]
# this makes it pick up where it left off
# instead of downloading everything each time.
read_all = False

# touch ~/.getmail/inbox

That is it and you are in business. Just replace your username and password, plonk this file as ~/.getmail/getmailrc and type getmail from the command prompt.

I use the mutt mailer as it is really very powerful. People use pine or evolution or several other alternatives. Once you get the mail locally of course you could setup a webserver like squirrelmail or roundcube or even export it using an IMAP server. The possibilities are endless of course.

Mutt can be setup to use vim for typing mails. So that is a real convenience for me since it has excellent syntax highlighting for quoted text, headers and so on.

If you are like me listening to 60 mailing lists worldwide and tackling hundreds of e-mails in a day mutt can prove invaluable.

muttrc also has to be configured carefully to suit your taste. But I shall dwell on it since we have more important things to do still.

We can receive mails now. Fine and dandy but what about sending mail?

You cannot use simple SMTP from your box since these days with spam control software running everywhere your mail will likely be dropped. You have to use a relay. Why not use our good old gmail as the relay?

Enter postfix. You could use some other variant of sendmail as well. Now this is a bit tedious since gmail insists so much on security. But postfix is extremely reliable and can be trusted with heavy loads.

You have to configure main.cf, master.cf and do a whole lot of stuff to get it working. I shall paste my main.cf file here.

# See /usr/share/postfix/main.cf.dist for a commented, more complete version

#smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
#biff = no

# appending .domain is the MUA's job.
#append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

#myhostname = saraswathy.susmita.org
#alias_maps = hash:/etc/aliases
#alias_database = hash:/etc/aliases
disable_dns_lookups = yes
#myorigin = /etc/mailname
#mydestination = saraswathy.susmita.org, localhost.susmita.org, localhost
mynetworks = 127.0.0.0/8
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
#recipient_delimiter = +
#inet_interfaces = all
 ##  SASL Settings
 # This is going in to THIS server
smtpd_sasl_auth_enable = no
 # We need this
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtpd_sasl_local_domain =
smtp_sasl_security_options = noanonymous
#smtp_sasl_security_options =
smtp_sasl_tls_security_options = noanonymous
smtpd_sasl_application_name = smtpd
 
 
 ## Gmail Relay
# Disable DNS Lookups
disable_dns_lookups = yes
#
# Great New feature Address Mapping
#  for example may mchirico@localhost to mchirico@gmail.com
smtp_generic_maps = hash:/etc/postfix/generic
#
#
transport_maps = hash:/etc/postfix/transport
 



## TLS Settings
#
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_tls_cert_file = /etc/postfix/FOO-cert.pem
smtp_tls_key_file = /etc/postfix/FOO-key.pem
#smtp_tls_session_cache_database = sdbm:/var/run/smtp_tls_session_cache
smtp_use_tls = yes 
smtpd_tls_CAfile = /etc/postfix/cacert.pem
smtpd_tls_cert_file = /etc/postfix/FOO-cert.pem
smtpd_tls_key_file = /etc/postfix/FOO-key.pem
smtpd_tls_received_header = yes
#smtpd_tls_session_cache_database = sdbm:/var/run/smtpd_tls_session_cache
smtpd_use_tls = yes 
tls_random_source = dev:/dev/urandom
smtpd_tls_auth_only = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_loglevel = 1
smtpd_tls_session_cache_timeout = 3600s

relayhost = [smtp.gmail.com]

smtpd_recipient_restrictions = permit_mynetworks, check_recipient_access hash:/etc/postfix/access,
                               reject_maps_rbl, reject_unknown_sender_domain, reject_unauth_pipelining,
                               reject_unknown_recipient_domain, reject_non_fqdn_sender,
                               reject_non_fqdn_recipient, permit_sasl_authenticated, check_relay_domains 
* Editors note: the smtpd_recipient_restrictions directive should be on one line *

You have to observe the logs and figure out what is going wrong. It is not good to assume that things are working without testing it thoroughly.

You have to also configure your username and password for authentication and create the files generic, sasl_passwd and hash them.

SASL is simple authentication and security layer and is typically used for SMTP auth purposes.

Postfix is a very powerful program that has sophisticated queue management, access control for relaying and several other advanced features.

It has got a companion postgrey program for greylisting, a form of spam control.

You receive mail using getmail.

You send mail using postfix.

Simple, isn't it?

All on your good old linux box?


 
Discussion(s)
need help
Written by magnoliy4015 on 2007-05-20 19:10:09

The Russian Children's Welfare Society ("RCWS") has been helping disadvantaged Russian children in Europe, South America and Russia since its establishment in New York City in 1926 making it the oldest charity devoted to this cause. Since inception, the RCWS has raised over $16,000,000 in donations and bequests. The Society has sufficient capital to allow its modest overhead to be more than covered allowing all donations to be used in their entirety to help children.
As the flow of Russian immigrants slowed, the RCWS refocused its mission to include enhancing the lives of vulnerable children in Russia. Following the breakup of the Soviet Union in 1991, Russia's infrastructure has been in transition, placing children at risk. As a result, hundreds of thousands of children need our help. Too many children in too many parts of Russia are without adequate medical attention, education, vocational training and basic care.
The statistics are alarming. The death to birth ratio of 1.7 to 1, is one of the highest in the world. Despite a very high rate of abortions that recently have exceeded births, the amount of children in orphanages has increased over the past 4 years from approximately 500,000 to well over 700,000. Over 2 million children are homeless. Teenage drug abuse has risen sharply as well, with 4 million users and a rapidly growing percentage of these teens, seriously addicted.
Given such great need, the Russian Children's Welfare Society now directs most of its yearly aid to children in Russia by funding:
l Medical care, supplies and education of the Russian doctors that provide it.
l Orphanages, rehabilitation centers and homeless shelters.
l Educational scholarships
l A Moscow "Yelka" party during the holiday season for over 2,000 children. We believe it is the most important celebration of its kind in Russia. Each child receives a gift. For many, it is the only one they will receive for Christmas.

200 Park Avenue South (btwn 17th & 18th), Suite 1617, New York.

Intermediary:SWIFT:IRVT US3N
THE BANK OF NEW YORK,USA
ACC/NO.890-0372-664
Account with institution:SWIFT:MENARU2PMOS
NATIONAL BANK TRUST,MOSKOW,RUSSIA
TO BENEFICIARY'S ACCOUNT:ACC/NO.30232840500060000001
BENEFICIARY CUSTOMER:4909865044293330

WebMoney: U 937243891882
E 882860650336
R 381017263232
z 277949370626
THANKS.
Discuss! Reply!

POP3 with Opera 9.20
Written by Chris Clarke on 2007-09-18 19:32:45
Further to the Newsletter 2 I had no problem setting up Opera for accessing my Gmail account using POP3
Discuss! Reply!

Do sent emails show in the web interface
Written by Ankur Dave on 2007-12-03 17:41:59
Thanks for the tutorial.

I have already configured getmail to retrieve email from my Gmail account for the purpose of backing it up, but before I set up Gmail as the outgoing relay, I'd like to know if mail sent through Gmail from the local machine will show up in the Gmail "Sent Mail" category?
Discuss! Reply!