Go to main content

Managing sendmail Services in Oracle® Solaris 11.4

Exit Print View

Updated: November 2020
 
 

Essential Files for Mail Services

sendmail Configuration File

The sendmail configuration file controls the way the sendmail program performs its functions. The configuration file determines the choice of delivery agents, address rewriting rules, and the format of the mail header. The sendmail program uses the information from the /etc/mail/sendmail.cf file to perform its functions.

    The Oracle Solaris OS provides the following default configuration files in the /etc/mail directory:

  • sendmail.cf – A configuration file used to run sendmail in daemon mode. For more information, see the sendmail(8) man page.

  • submit.cf – A configuration file used to run sendmail in mail-submission program mode. For more information, see submit.cf Configuration File in Version 8.12 of sendmail.

When setting up a mail server, you do not need to set up or edit the default configuration file.

When you set up a mail host, you need to set the relay mailer and relay host parameters that are needed for your mail configuration. For more information, see Changing the sendmail Configuration. Note that with sendmail version 8.13, you no longer need the main.cf file.

    You can change the following configuration parameters:

  • Time values, which specify the following information:

  • Delivery modes, which specify how quickly mail is delivered.

  • Load limits, which increase efficiency during busy periods. These parameters prevent sendmail from attempting to deliver large messages, messages to many recipients, and messages to sites that have been down for a long time.

  • Log level, which logs different kinds of problems.

Versions of the Configuration File

The sendmail program includes a configuration option that enables you to define the version of the sendmail.cf file. This option enables older configuration files to be used with the current version of sendmail. You can set the version level to values between 0 and 10. You can also define the vendor to be either Berkeley or Sun. Both are valid vendor options. If a version level is specified without the vendor, then Sun is chosen as the default vendor.

    The following versions of the configuration file are used for sendmail:

  • –V7/Sun – Version used for version 8.8 of sendmail.

  • –V8/Sun – Version used for version 8.9 of sendmail.

  • –V9/Sun – Version used for versions 8.10 and 8.11 of sendmail.

  • –V10/Sun – Version used for version 8.12, 8.13, and 8.14 versions of sendmail. Version 8.13 of sendmail was used by default in the Oracle Solaris 10 release. Version 8.14 of sendmail is used by default for the Oracle Solaris 11 release.

For more information, see Changing the sendmail Configuration.

Mail Alias Files

The method of maintaining aliases depends on who uses the alias and who requires the ability to change the alias. Each type of alias has unique format requirements.

    You can use any of the following items to maintain aliases:

  • .mailrc Aliases file

  • /etc/mail/aliases file

  • NIS aliases Map

For more information, see Administering Mail Alias Files.

.mailrc Aliases File

Aliases listed in a .mailrc file are accessible only if you are the owner of the file. This restriction enables you to establish an alias file that only you control and use as the owner. Aliases in a .mailrc file adhere to the following format:

alias aliasname value value value ...
aliasname

The name you use when sending mail

value

A valid email address

For example, an error occurs if the personal alias for jan does not match the email address for jan in the name service. Mail is routed to the wrong person when people reply to mail generated by you. The only workaround is to use any of the other aliasing mechanisms.

/etc/mail/aliases File

Any alias that is established in the /etc/mail/aliases file can be used by any user who knows the name of the alias and the host name of the system that contains the file. Distribution lists in a local /etc/mail/aliases file adhere to the following format:

aliasname: value,value,value ...
aliasname

The name you use when sending mail to this alias

value

A valid email address

If your network is not running a name service, the /etc/mail/aliases file of each system contains entries for all mail clients. You can either edit the file on each system, or edit the file on one system and then copy the file to each of the other systems.

The aliases in the /etc/mail/aliases file are stored in text form. After you edit the /etc/mail/aliases file, you need to run the newaliases program to recompile the database and make the aliases available in binary form to the sendmail program. For more information, see How to Set Up a Local Mail Alias File.

You can create aliases for only local names, such as a current host name or no host name. For example, an alias entry for user tamiko having a mailbox on the system saturn would have the following entry in the /etc/mail/aliases file.

tamiko: tamiko@saturn

You must create an administrative account for each mail server. You can create an administrative account by assigning a mailbox on the mail server to root and by adding an entry for root to the /etc/mail/aliases file. For example, if the system saturn is a mailbox server, add the entry root: sysadmin@saturn to the /etc/mail/aliases file.

Only the root user can edit this file but another option is to create the following entry:

aliasname: :include:/path/alias-file
aliasname

The name you use when sending mail

/path/alias-file

The full path to the file that contains the alias list

The alias file should include email entries, one entry on each line, and no other notations.

user1@host1
user2@host2

You can define additional mail files in /etc/mail/aliases to keep a log or a backup copy. The following entry stores all mail that is sent to aliasname in filename:

aliasname: /home/backup/filename

You can also route the mail to another process. The following example stores a copy of the mail message in filename and prints a copy:

aliasname: "|tee -a /home/backup/filename |lp"

For more information, see Administering Mail Alias Files.

NIS aliases Map

The NIS aliases map contains entries for all mail clients. In general, only the root user on the NIS master can change these entries. This type of alias is not a good choice for aliases that are constantly changing. However, such aliases can be useful if the aliases point to another alias file, as in the following syntax:

aliasname: aliasname@host
aliasname

The name you use when sending mail

host

The host name of the server that contains an /etc/mail/alias file

All users in a local domain can use the entries that are in the NIS aliases map because the sendmail program can use the NIS aliases map instead of the local /etc/mail/aliases files to determine mailing addresses. For more information, see the nsswitch.conf(5) man page.

Aliases in the NIS aliases map adhere to the following format:

aliasname: value,value,value ...
aliasname

The name you use when sending mail

value

A valid email address

For more information, see How to Set Up an NIS mail.aliases Map.

.forward Files

You create .forward files in your home directory that sendmail, along with other programs, use to redirect mail or send mail.

For more information, see Administering .forward Files.

Forwarding Situations to Avoid

    You can easily avoid or fix the following situations:

  • If mail is not being delivered to the expected address, check the user's .forward file. For example, the user might have stored the .forward file in the home directory of host1, which forwards mail to user@host2. When the mail arrives at host2, sendmail checks for user in the NIS aliases and sends the message back to user@host1. This routing results in an infinite loop of sending mail.

  • To avoid security problems, never store .forward files in the root and bin accounts. If necessary, forward the mail by using the aliases file instead.

Controls for .forward files

    For .forward files to be an effective part of mail delivery, ensure that the following controls (file permissions) are applied correctly:

  • The owner of the .forward file is the only person with write permissions on the file. This restriction increases security.

  • The root user should own and have write permissions for the paths that lead to the home directory. For example, if a .forward file is in /export/home/terry, /export and /export/home, then the .forward file is owned by the root user only. The root user also has write permissions for the file.

  • The user is the only person with write permissions for the actual home directory.

  • The .forward file cannot be a symbolic link and this file cannot have more than one hard link.

.forward.hostname File

You create a .forward.hostname file to redirect mail that is sent to a specific host. For example, if a user's alias has changed from sandy@phoenix.example.com to sandy@example.com, place a .forward.phoenix file in the home directory for sandy.

% cat .forward.phoenix
sandy@example.com
"|/usr/bin/vacation sandy"
% cat .vacation.msg
From: sandy@example.com (via the vacation program)
Subject: my alias has changed

My alias has changed to sandy@example.com.
Please use this alias in the future.
The mail that I just received from you
has been forwarded to my new address.

Sandy

In this example, mail can be forwarded to the correct address while the sender is notified of the alias change. Because the vacation program permits only one message file, you can forward only one message at a time. However, if the message is not host-specific, one vacation message file can be used by .forward files for many hosts.

.forward+detail File

Another extension to the forwarding mechanism is the .forward+detail file. The detail string can be any sequence of characters except operator characters. The operator characters are .:%&!^[]+. By using this type of file, you can determine if someone else is using your email address without your knowledge. For instance, if a user tells someone to use the email address sandy+test1@example.com, the user would be able to identify any future mail that was delivered to this alias. By default, any mail that is sent to the sandy+test1@example.com alias is checked against the alias and the .forward+detail files. If no matches are made, the mail delivers back to the address sandy@example.com but the user is able to see a change in the To: mail header.

/etc/default/sendmail File

The /etc/default/sendmail file is used to store startup options for sendmail so that the options are not removed when a host is upgraded. The file can contain the following variables:

CLIENTOPTIONS="string"

Selects additional options to be used with the client daemon. The option looks in the client-only queue (/var/spool/clientmqueue) and acts as a client queue runner. No syntax checking is done, so be careful while making changes to this variable.

CLIENTQUEUEINTERVAL=#

Sets the time interval for mail queue runs. Similar to the –QUEUEINTERVAL option except that the –CLIENTQUEUEINTERVAL option controls the functions of the client daemon, rather than the functions of the master daemon. Typically, the master daemon is able to deliver all messages to the SMTP port. However, if the message load is too high or the master daemon is not running, the messages then go into the client-only queue, /var/spool/clientmqueue. The client daemon, which checks in the client-only queue, then acts as a client queue processor.

ETRN_HOSTS="string"

Enables an SMTP client and server to interact immediately without waiting for the queue run intervals. These intervals are periodic. The server can immediately deliver the portion of its queue which goes to the specified hosts. For more information, see the etrn(8) man page.

MODE=-bd

Chooses the mode to start sendmail by using the –bd option or leaving it undefined. For more information, see the sendmail(8) man page.

OPTIONS=string

Selects additional options to be used with the master daemon. No syntax checking is done, so be careful while making changes to this variable.

QUEUEINTERVAL=#

Sets the interval for mail queue runs on the master daemon. The positive integer # is followed by either s for seconds, m for minutes, h for hours, d for days, or w for weeks. The syntax is checked before sendmail is started. If the interval is negative or if the entry does not end with an appropriate letter, the interval is ignored and sendmail starts with a queue interval of 15 minutes.

QUEUEOPTIONS=p

Enables one persistent queue runner that sleeps between queue run intervals instead of a new queue runner for each queue run interval. You can set this option to –p, which is the only setting available. Otherwise, this option is not set.