Mail in ubuntu

Installations

sudo apt-get install mutt fetchmail ssmtp

Configuration

fetchmail ~/.fetchmail

set postmaster ‘myusername’
set no bouncemail

poll mail.tpg.com.au
with protocol pop3
username users  password psswd1 keep is myusername;

poll pop.gmail.com
with protocol pop3
port 995
username gmailuser password gmailpasswd keep is myusername
ssl;

ssmtp  sudo vi /etc/ssmtp/ssmtp.conf

add

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=mail.tpg.com.au

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=myhost.org

mutt ~/.muttrc

auto_view text/html
set from=” <tpgusername@tpg.com.au>”
set editor=/usr/bin/vi

set sendmail=”/usr/sbin/ssmtp “
#
#
set mail_check=60 # check for new mail every 60 seconds
set timeout=15   # after 15 secs of no keypresses, start checking for new mail

Use SSMTP with gmail

We need to then need to edit, ‘/etc/ssmtp/ssmtp.conf’:

root=username@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=username@gmail.com
UseSTARTTLS=YES
AuthUser=username
AuthPass=password
FromLineOverride=YES

Then add each account that you want to be able to send mail from by editing, ‘/etc/ssmtp/revaliases‘:

root:username@gmail.com:smtp.gmail.com:587
localusername:username@gmail.com:smtp.gmail.com:587

Test my ISP mailer

telnet mail.tpg.com.au 25

help

quit

Read and send mails

to get mail fetchmail

to read mail mutt

sendmail via ssmtp

Note, although ssmtp is used to substitute for sendmail to deliver mail to outside, ‘sendmail’ is still needed for fetchmail to deliver mail to local mailserver.

Fix: fetchmail without sendmail

fetchmail -m ‘/usr/bin/procmail -d %T’

Use the native sendmail

 1. Set your authorization informations by adding following line to /etc/mail/access file:
AuthInfo:relay.dnsexit.com "U:USERNAME" "P:PASSWORD" "M:PLAIN"
   Note: Replace USERNAME and PASSWORD with the DNSEXIT mail relay username and PASSWORD.

 2. Add following lines to /etc/mail/sendmail.mc (check if apropriate settings doesn't already exists):

define(`SMART_HOST', `relay.dnsexit.com')
FEATURE(`access_db')

3. Update sendmail.cf and access.db files:   

# cd /etc/mail
# m4 sendmail.mc >sendmail.cf
# makemap hash access <access 

4. Reload or restart sendmail: 
# /etc/init.d/sendmail restart

5. mark all mails read
Create a macro.
macro index M "T.*\n;WN" "Mark all messages as read"

This will make an “M” keystroke mark all messages in the current folder (in the index view) as read.

Leave a comment