Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications

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 = SimplePOP3SSLRetrieverserver = pop.gmail.comusername = foopassword = bar[destination]# this can be changed to Maildir, etc. RTFM.type = MDA_externalpath = /usr/bin/procmailunixfrom = 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/aliasesdisable_dns_lookups = yes#myorigin = /etc/mailname#mydestination = saraswathy.susmita.org, localhost.susmita.org, localhostmynetworks = = procmail -a "$EXTENSION"mailbox_size_limit = 0#recipient_delimiter = +#inet_interfaces = all ## SASL Settings # This is going in to THIS serversmtpd_sasl_auth_enable = no # We need thissmtp_sasl_auth_enable = yessmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtpd_sasl_local_domain =smtp_sasl_security_options = noanonymous#smtp_sasl_security_options =smtp_sasl_tls_security_options = noanonymoussmtpd_sasl_application_name = smtpd ## Gmail Relay# Disable DNS Lookupsdisable_dns_lookups = yes## Great New feature Address Mapping# for example may mchirico@localhost to mchirico@gmail.comsmtp_generic_maps = hash:/etc/postfix/generic##transport_maps = hash:/etc/postfix/transport ## TLS Settings#smtp_tls_CAfile = /etc/postfix/cacert.pemsmtp_tls_cert_file = /etc/postfix/FOO-cert.pemsmtp_tls_key_file = /etc/postfix/FOO-key.pem#smtp_tls_session_cache_database = sdbm:/var/run/smtp_tls_session_cachesmtp_use_tls = yes smtpd_tls_CAfile = /etc/postfix/cacert.pemsmtpd_tls_cert_file = /etc/postfix/FOO-cert.pemsmtpd_tls_key_file = /etc/postfix/FOO-key.pemsmtpd_tls_received_header = yes#smtpd_tls_session_cache_database = sdbm:/var/run/smtpd_tls_session_cachesmtpd_use_tls = yes tls_random_source = dev:/dev/urandomsmtpd_tls_auth_only = yessmtp_tls_note_starttls_offer = yessmtpd_tls_loglevel = 1smtpd_tls_session_cache_timeout = 3600srelayhost = [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?

Rate This Article: poor excellent
Comments about this article
need help
writen 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.
RE: need help written by magnoliy4015:
POP3 with Opera 9.20
writen 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
RE: POP3 with Opera 9.20 written by Chris Clarke:
Do sent emails show in the web interface
writen 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?
RE: Do sent emails show in the web interface written by Ankur Dave:
writen by: Mark on 2008-05-30 22:04:28
I wrote an article on downloading/backing up from gmail with fetchmail. You can check it out here: http://www.marksanborn.net/freebsd/using-fetchmail-to-backup-gmail-with-freebsd/ Its written for FreeBSD but it will work with Linux too.
RE: Mr. written by Mark:
mail service
writen by: alagiri on 2009-02-03 02:28:27
what is oxigen in mail server ? tell me somthing abt oxigen!!!!!!!!!!!!!!!!!!!!
RE: mail service written by alagiri:
writen by: tgp1994 on 2009-12-02 22:42:12
Couldn't you also just go to www.gmail.com and use your email there?
RE: ?? written by tgp1994:

Comment title: * please do not put your response text here