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/inboxThat 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 = 127.0.0.0/8mailbox_command = 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? |