Skip to content

mail

Here is a section about mail in general, and about setting up a mail server. My test is mainly for an internal server used to test the smtp module of askmet /libego.

mailx

As a mail agent i used mail (the command line program) but if you lost that (for instance since removing exim4 also seems to remove mail) : it is named mailx in apt

postfix

I set up postfix on both the server and the client, simply by apt-getting it and using the 'internet-mail' option (the default) and filling in the correct .klopt.org domain names when asked. This directly worked: my server is dynamix-177.klopt.org, when typing

direct mail
mail kees@dynamix-177.klopt.org.net 

The mail entered reached dynamix-177 without problems, read it with 'mail' logged in to the kees account. here is a log of the 'working' communication (server side):

log
1
2
3
4
5
Jan 10 13:58:46 dynamix-177 postfix/smtpd[9757]: 20B6283C4CF: client=dynamix-212.klopt.org[10.10.180.212]
Jan 10 13:58:46 dynamix-177 postfix/cleanup[9796]: 20B6283C4CF: message-id=
Jan 10 13:58:46 dynamix-177 postfix/qmgr[6914]: 20B6283C4CF: from=, size=565, nrcpt=1 (queue active)
Jan 10 13:58:46 dynamix-177 postfix/local[9798]: 20B6283C4CF: to=, relay=local, delay=0.04, delays=0.01/0/0/0.02, dsn=2.0.0,  status=sent (delivered to command: procmail -a "$EXTENSION" )
Jan 10 13:58:46 dynamix-177 postfix/qmgr[6914]: 20B6283C4CF: removed

The client logs are almost identical, so left out here. It seems postfix does use smtp to send the mail, this is what i use in askmet to send mail as well, so using dynamix-177.klopt.org as smtp server and kees@dynamix-177.klopt.org as recipient everything works out of the box. Big points for postfix !!

exim

internet mail

Since this is the default mailer already installed (only mailing locally!), here is how to setup mailing outside for a machine that has itself an external ip address.

setup exim4
dpkg-reconfigure exim4-config

Choose the internet option just like postfix.

using smarthost

If however you have an internal machine, you better use a smarthost in your setup. It is possible to setup the smarthost as well, but i chose for the easier solution using google for the relaying. visit It explains it perfectly, but for 404 reasons i will repeat it here :

Step 1

  • Run dpkg-reconfigure exim4-config
  • Choose mail sent by smarthost; received via SMTP or fetchmail
  • Type System Mail Name: e.g. company.com
  • Type IP Addresses to listen on for incoming SMTP connections: 127.0.0.1
  • Leave Other destinations for which mail is accepted blank
  • Leave Machines to relay mail for: blank
  • Type Machine handling outgoing mail for this host (smarthost): smtp.gmail.com::587
  • Choose NO, don't hide local mail name in outgoing mail.
  • Chose NO, don't keep number of DNS-queries minimal (Dial-on-Demand).
  • Choose mbox
  • Choose NO, split configuration into small files
  • Mail for postmaster. Leaving blank will not cause any problems though it is not recommended

Step 2

  • Open the file /etc/exim4/exim4.conf.template

  • Find the line .ifdef DCconfig_smarthost DCconfig_satellite and add the following in that section

    send_via_gmail:
        driver = manualroute
        domains = ! +local_domains
        transport = gmail_smtp
        route_list = * smtp.gmail.com
    
  • If you have any other smarthost defined with "domains = ! +local_domains" remove that smarthost.

  • Find the "begin authenticators". In that section add the following

    gmail_login:
         driver = plaintext
         public_name = LOGIN
         client_send = : yourname@gmail.com : YourGmailPassword
    
  • Make sure you have no other authenticators with the same public_name (LOGIN). Comment them out if needed (Thanks Jakub for reminding me)

  • Find the comment "transport/30_exim4-config_remote_smtp_smarthost". In that section add

    gmail_smtp:
          driver = smtp
          port = 587
          hosts_require_auth = $host_address
          hosts_require_tls = $host_address
    

Step 3

  • Run update-exim4.conf
  • Do /etc/init.d/exim4 restart

That should be it. You can test by using a command line mail client.

mail queue

I had a problem where we got on a blocked list probably because of continues retries of some example messages. Listing the queue content can be done with :

mail queue
mailq

Result

output
4d   918 1MLGFB-00005f-1r 
       D kees@klopt.org
         mary@example.com
         kelly@example.com
         birthdayarchive@example.com
         birthdaycheck@example.com

4d   918 1MLGFR-00005l-23 
       D kees@klopt.org
         mary@example.com
         kelly@example.com
         birthdayarchive@example.com
         birthdaycheck@example.com

Deleting items from the queue :

delete items
exim4 -Mg 1MLGFB-00005f-1r
exim4 -Mg 1MLGFR-00005l-23

gmail

Ok.. i'm already hating google more than Microsoft. They are closing in on apple.... It is totally not possible to use different gmail accounts interchangeably, after you have been logged out from one account for the 100th time, you will see that. When you want to forward your messages to one account, you are in trouble still. First there are no folders, only labels. And it takes some fiddling to get that working like you might expect:

  • forward all mail from the other account(s)
  • make those mail appear under a separate folder(label)
  • and for god sake do not mark them as read

First you need to define the label :

  • Choose :"Create new label" in the left part, or click 'more' to reveal that link.
  • Add a label for each of your mail addresses or one if you like that better.
  • It will appear in the left bar, you can there add a color by clicking on arrow next to it.
  • If you also choose here to only show the label in the label list 'only when unread', it will be under the 'more/less' when there is no new mail, and above/visible when you have new mail.
  • Then you need a filter, under settings (under the 'gear' icon at the right) choose 'filters' and create a new filter for each mail address you forwarded.
  • Fill that forwarded address in the to field and click 'continue'.
  • In the next screen choose 'apply label' and you can find your created label in the dropdown box.
  • But do not forget to also check 'skip the inbox (archive it)' if of course you only want this mail to appear in it's labels 'folder'.
  • Now you also have to manage the forwarding itself : log in to that account and go to the 'forwarding and.. etc' page.
  • Simply add the forwarding address.
  • Logout and back into the receiving account again.
  • You should have received a validation mail, so acknowledge that.
  • Chances are you now have to go back to the other account again because the forwarding was disabled and you have to enable it again.

: do not make the mistake of testing it from the receiving account because all these messages will be marked as 'read' for some reason (because you sent it yourself?, and thus already read it ??).

Wait for somebody else to mail it or test it from another account.