Table of Contents
AIX Mail
Because AIX is by default delivered with sendmail, and cronjobs results are delivered to the associated users mailbox here is some information about AIX sendmail and how to deal with the day-to-day administration.
Send Mail Out
In case you have a working email system configured on your box, this is how you actually send mail:
Note: I replaced the @ in the mail addresses by a _ because of spam. Use correct email addresses
Manually
/home/sjoerd>mail -s "testsubject" sjoerd_getshifting.com Test body . Cc:
- -s : subject
- After hitting enter you can start typing the body of the mail. Finish by entering a single dot “.” on a line and hit ENTER
Automatically
You can mail logfiles for example by catting them into the mail:
/home/sjoerd>cat smit.log | mail -s "logfile" sjoerd_getshifting.com
Multiple Receivers
Add email addresses to the mail command:
/home/sjoerd>cat smit.log | mail -s "logfile" sjoerd_getshifting.com info_getshifting.com sjoerd.hooft_getshifting.com
Forward Local Mail
The first thing I always do is create a forward for all local mail. This has the benefits that you can redirect the mail to a managed email environment like, for example, groupwise or exchange. Than you can set rules on them, view them everywhere in the world, deliver them to standby email enabled phones like blackberry and much much more. Also, it will (just a little though) lower the required I/O and storage for the user. We
To forward local mail create a new file named “.forward” (the leading period is mandatory) in the users home directory:
sjoerd@server:/home/sjoerd>cat .forward sjoerd_getshifting_com
Note: Fill in an existing email address of course, this is where the mail will be send.
Sendmail Options
Default Settings
# my official domain name # ... define this only if sendmail cannot automatically determine your domain #Dj$w.Foo.COM Djshift.local # "Smart" relay host (may be null) DS10.10.10.10
Security Settings
# privacy flags O PrivacyOptions=goaway
Dontblamesendmail
This setting makes sendmail less secure but could be necessary when you get warnings like this:
4 mail mail warning message forwarded from appserver: sendmail[430420]: o916t011168410: forward /var/data/appuser/.forward: world writable directory 01 Oct 2010, 08:55:00 5 mail mail warning message forwarded from appserver: sendmail[430420]: o916t011168410: forward /var/data/appuser/.forward.appserver: world writable directory 01 Oct 2010, 08:55:00 6 mail mail warning message forwarded from appserver: sendmail[430420]: o916t011168410: forward /var/data/appuser/.forward+: world writable directory 01 Oct 2010, 08:55:00 7 mail mail warning message forwarded from appserver: sendmail[430420]: o916t011168410: forward /var/data/appuser/.forward.appserver+: world writable directory
as well as these warnings but then for “group writable directory”.
Some more information about this:
The biggest surprise is likely to come from .forward and :include: files in unsafe directory paths (directory paths which are group or world writable). This is no longer allowed. This would mean that if user joe's home directory was writable by group staff, sendmail would not use his .forward file. This behavior can be altered, at the possible expense of system security, by setting the DontBlameSendmail option. Items from these unsafe .forward and :include: files will be marked as unsafe addresses – the items can not be deliveries to files or programs. This behavior can also be altered via DontBlameSendmail.
I've set:
O DontBlameSendmail=forwardfileinunsafedirpath, forwardfileinunsafedirpathsafe
The first flag allows the forward file to be read, the second allows the items in the file to be marked as safe for file and program delivery.
Sendmail commands
Start Sendmail
startsrc -s sendmail -a "-bd"
Stop Sendmail
stopsrc -s sendmail
Restart Sendmail
stopsrc -s sendmail; startsrc -s sendmail -a "-bd"
Sendmail Version
echo \$Z | /usr/sbin/sendmail -bt -d0
Extra Sources
Local Mail
Delete all local mail for a user:
cd /var/spool/mail vi username :%d :wq
Delete all local mail as a user:
mail
d *
Other commands
- ? : Display commands
f *
: DISPLAY headers
Mail examples
> mail -s "test" sjoerd_getshifting_com test . Cc: > cat shell_func.sh function mail_att_to_me() { (for k in ${1}; do uuencode $k ${k##*/}; done) | \ mailx -r sjoerd-noreply_getshifting_com -s "Attachment(s) for me" sjoerd_getshifting_com }