Archive

Archive for December, 2009

sSMTP revaliases, aliases and mail.rc

December 2nd, 2009 4 comments

I already wrote about sending mails with ssmtp, a simple alternative to sendmail. But since I got a few questions (and I tend to forget myself) how to use ssmtp’s revaliases-file, here is a short reminder:

/etc/revaliases, allows you to map a local user to a specific ‘From:’ address on outbound mail and to route that mail through a specific mailhub. But it will not rewrite the ‘To:’ address according to the local user who should receive the mail.

Usually, you would add aliases to /etc/aliases to ensure that a local user (receiving a mail) is mapped to a valid eMail address. But as the documentation clearly says (if you actually read it), ssmtp does not use /etc/aliases.

The solution turns out to be letting mail handle the alias – which is done by configuring aliases in /etc/mail.rc

set ask askcc append dot save crt
ignore Received Message-Id Resent-Message-Id Status Mail-From Return-Path Via Delivered-To
alias root root<yourname@domain.com>
alias localuser localuser<yourname@domain.com>

You can test it with with:

# echo test | mail -s "testing ssmtp" localuser

The mail will actually be delivered to yourname@domain.com (since ‘localuser’ is mapped to this address in /etc/mail.rc).

Enjoy!

Resources:
http://www.linux.com/archive/feature/132006
http://greybeardedgeek.net/?p=17

Categories: Uncategorized Tags: ,

Find empty folders on Linux

December 1st, 2009 No comments

Well, there is no native command (at least, afaik), but you can use find to easily identify empty folders (which maybe helpful for maintenance, etc.):

# find /path -type d -empty


Find empty folder and list

# find /path -type d -empty -exec ls -ld {} \;


Find empty folder and save as temporary file

# find /path -type d -empty -exec ls -ld >> /tmp/savefiles.txt {} \;


Find empty folder and delete

# find /path -type d -empty -exec rmdir {} \;

See also find manpage

Categories: Uncategorized Tags: