Mailing List Message #92700
From: John Rudd <>
Subject: Problem with legacy "mail" program
Date: Sat, 22 Sep 2007 23:35:38 -0700
To: CommuniGate Pro Discussions <>, Technical Support <>

The documentation for the legacy "mail" program says this:

mail [-iInv]  [-d base-directory]
     [-s subject] [-f from-address]
     [-c Cc-addresses] [-b bcc-addresses] to-addresses

In order to be compatible with legacy unix "mail" commands, the to-addresses need to be _space_ delimited instead of comma delimited. By providing a symlink from /usr/bin/mailx to /opt/CommuniGate/mail, for example, scripts called from cron which invoke the following:

/usr/bin/mailx -s "Nightly Report" sysadmin@domain applicationadmin@domain servicemanager@domain

break with the following error:

usage: /bin/mailx [-iInv] [-d BaseDirectory] [-s Subject] [-c addresses] [-b addresses] [addresses]

Yet, the space delimited syntax is the _correct_ syntax for the unix mail command (the thing which the CGP mail command is attempting to emulate).  The comma delimited syntax that CGP's mail command expects is NOT the correct syntax.

My recommendation is to allow all 3 of the following:

1) allow comma delimited addresses for Cc-addresses bcc-addresses and to-addresses (same behavior as now)

2) allow multiple -c and -b arguments in order to specify multiple recipients, adding each extra argument to the list of that type of recipient (thus "mail -c tom -c dick harry" is semantically the same as "mail -c tom,dick harry").

3) if there are extra words on the command line past the to-addresses, add them to the list of to-addresses, providing the correct mail/mailx behavior.

This will allow both comma and space delimited syntax to work, even allowing both to work at the same time.  This provides compatibility with both the legacy unix commands AND the legacy CGP legacy commands.

(in order to keep solaris patches from re-enabling sendmail, I have a script that runs out of /var/CommuniGate/ which checks to be sure /usr/lib/sendmail /usr/bin/mail and /usr/bin/mailx are all symlinks to the legacy CGP programs, or replaces them with symlinks if they're not ... so even if solaris tries to start sendmail, it will fail because the -bd argument isn't supported by CGP's legacy programs)

Also, it might be a good idea to add -E to the list of arguments for "mail" (solaris, by default, runs "/bin/mail -E" from /etc/profile and /etc/.login, to see if you have new mail).  My suggestion is that the -E argument should cause an exit status of 1 (no mail).

For those who are interested, here's the script I run out of


sub movefile {
   my $file = shift(@_);
   my $i = shift(@_);
   my $inc = $i + 1;
   my $oldfile = ($i) ? ($file . "." . $i) : ($file);
   my $newfile = $file . "." . $inc;

   if (-e $newfile) {
      movefile($file, $inc);
   print "renaming $oldfile to $newfile\n";
   rename($oldfile, $newfile);

sub fixlink {
   my $file = shift(@_);
   my $target = shift(@_);
   my ($i);

   unless ( (-l $file) && (readlink($file) eq $target) ) {
      movefile($file, 0);
      print "symlinking $file -> $target\n";
      symlink($target, $file);

fixlink("/usr/lib/sendmail", "/opt/CommuniGate/sendmail");
fixlink("/usr/bin/mailx", "/opt/CommuniGate/mail");
fixlink("/usr/bin/mail", "/opt/CommuniGate/mail");

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster