Modernisation
[infodrom/calendar] / mail-calendar
index 428ca54..64e2e1b 100755 (executable)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 #   mail-calendar - send information about historical dates
-#   Copyright (c) 2002,3  Martin Schulze <joey@infodrom.org>
+#   Copyright (c) 2002,3,18  Joey Schulze <joey@infodrom.org>
 #
 #   This program is free software; you can redistribute it and/or modify
 #   it under the terms of the GNU General Public License as published by
 #   along with this program; if not, write to the Free Software
 #   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
 
-#   http://cvs.infodrom.org/calendar/mail-calendar?cvsroot=infodrom
-#   :pserver:anonymous@cvs.infodrom.org:/var/cvs/infodrom co calendar/mail-calendar
-#  
-#   $Id$
+#   git clone git://git.infodrom.org/infodrom/calendar
 
 #
 #   Important note: this program requires the FreeBSD version of
@@ -78,22 +75,26 @@ de_DE)
        opt_dateform="%d. %B"
 esac
 
-secs=$[ $opt_advance * 86400 ]
+secs=$(( $opt_advance * 86400 ))
 
-c_date=`date -d now+${secs}seconds +%d.%m`
+c_date=`date -d now+${secs}seconds +%m%d`
 s_date=`LANG=$opt_lang date -d now+${secs}seconds "+$opt_dateform"`
 
-tmp=`tempfile`
+tmp=$(mktemp)
 trap 'rm -f $tmp' INT EXIT
 
-calendar -l 0 -w 0 -t $c_date > $tmp
+LC_CTYPE=en_US.ISO-8859-1 calendar -l 0 -e 0 -w -t $c_date|iconv -c -f utf8 -t iso8859-1 > $tmp
 
 if [ -s $tmp ]
 then
     (
+       echo "From: $(getent passwd $LOGNAME|cut -d: -f5|cut -d, -f1) <$LOGNAME@$(hostname -f)>"
        echo "Subject: $opt_subject $s_date"
        echo "To: $opt_to"
+       echo "Content-Type: text/plain; charset=iso-8859-1"
+       echo "Content-Disposition: inline"
+       echo "Content-Transfer-Encoding: 8bit"
        echo
        cat $tmp
-    ) | /usr/sbin/sendmail "$opt_to"
+    ) | LANG=$opt_lang /usr/sbin/sendmail "$opt_to"
 fi