Ubuntu Smart Host from Home

Ubuntu Intrepid Ibex Sendmail Smarthost configuration - I can use pine from home to send email through my ISP provider - good for Nagios running at home monitoring remote systems.. On the list is get md5 tested and setup.

This is all done as root/sudo commands (use "sudo su -" to get become and stay root)

  1. Install sendmail - make sure m4 and makemap are installed.
  2. root@host:/etc/mail# cd /etc/mail
    
  3. Edit /etc/mail/sendmail.mc
    # define smart host - using port 25, can set to whatever you use...
    define(`SMART_HOST', `smtp.sbcglobal.yahoo.com')
    FEATURE(`access_db')
    define(`RELAY_MAILER_ARGS', `TCP $h 25')dnl
    dnl #
    
  4. Edit /etc/mail/access
    # Smart host - email from home - about how mine is set up through Pac Bell/SBC/AT&T/Yahoo conglomerate
    AuthInfo:[smtp.sbcglobal.yahoo.com] "U:user@sbcglobal.net" "P:pAsSwoRd" "M:PLAIN"
    
  5. Add this in the "Features" section of sendmail.mc file:
    dnl #
    dnl # Allow address rewriting
    FEATURE(masquerade_envelope) FEATURE(genericstable, `hash -o /etc/mail/genericstable')
    GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain')
    dnl #
    
  6. Create /etc/mail/genericsdomain
    root@host:/etc/mail# hostyname -f > genericsdomain
    
  7. Create a couple email-rewrites (thanks to notes from here ) in /etc/mail/genericstable This is needed because your declared "from" address needs to match something that sbcglobal.net - now AT&T Yahoo! email needs to know about, which is why I am adding the rewrite to my home sendmail config..
    root@host:/etc/mail# cat genericstable
    root	user@sbcglobal.net
    user	user@sbcglobal.net
    
  8. edit /etc/aliases if needed:
    root@host:/etc/mail# cat /etc/aliases
    # Added by installer for initial user
    root:	user
    clamav: root
    
  9. Then run newlaises
    root@host:/etc/mail# newaliases 
    /etc/mail/aliases: 2 aliases, longest 5 bytes, 19 bytes total
    root@host:/etc/mail#
    

    ... for root can also use .forward files

  10. Execute these commands - can just cut and paste these
    root@host:/etc/mail# makemap hash /etc/mail/access.db < /etc/mail/access
    root@host:/etc/mail# makemap -r hash /etc/mail/genericstable.db < /etc/mail/genericstable
    root@host:/etc/mail# m4 sendmail.mc > /etc/mail/sendmail.cf
    

Restart sendmail, fire up pine (look for alpine package), test it out.

* I had problems - errors in /var/log/mail.log showed:

Aug 30 18:15:36 host sm-mta[29605]: gethostbyaddr(192.168.122.1) failed: 1
Aug 30 18:15:36 host sm-mta[29623]: starting daemon (8.14.3): SMTP+queueing@00:10:00
Aug 30 18:15:46 host sendmail[29628]: gethostbyaddr(192.168.122.1) failed: 1

.. because the IP 192.168.122.1 was not listed in /etc/hosts - added it, gave it the same hostname as the machine, restarted sendmail, ran sendmail -q and mail successfully sent out.

(1) http://does-not-exist.org/roessler/genericstable.html "sendmail address rewriting mini-HOWTO"