Skip to content

Sendmail

Sendmail

  1. The sendmail program is installed by default. Type rpm -q sendmail to view sendmail version number.

  2. By default, the date for /etc/mail/*.db is not correct and therefore you need to re-make the *.db file before you can start sendmail properly.

    makemap hash /etc/mail/access < /etc/mail/access

    makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

    makemap hash /etc/mail/domaintable < /etc/mail/domaintable

    makemap hash /etc/mail/mailertable < /etc/mail/mailertable

  3. sendmail.mc is a macro config file used to generate the sendmail.cf. You will have to regenerate the sendmail.cf by running this macro config through the m4 preprocessor. By default, sendmail does not accept email over the network except localhost. Comment out the line in sendmail.mc

    DAEMON_OPTIONS(‘Port=smtp,Addr=127.0.0.1, Name=MTA’)

    to

    dnl DAEMON_OPTIONS(‘Port=smtp,Addr=127.0.0.1, Name=MTA’)

  4. Create the /etc/sendmail.cf file from /etc/mail/sendmail.mc after the modification. Make sure that sendmail-cf.version.rpm is installed before you can run the M4 preprocessor.

    m4 /etc/mail/sendmail.mc > /etc/sendmail.cf

  5. Restart sendmail.

Mail Aliases

  1. Mail alias is a powerful features that enable mail to be directed to mailboxes that are alternate names for users or processes on a destination host. For example, it is common practice to have feedback or comments relating to a World Wide Web server to be directed to “webmaster.” Often there isn’t a user known as “webmaster” on the target machine, instead it is an alias of another system user. Another common use of mail aliases is exploited by mailing list server programs in which an alias directs incoming messages to the list server program for handling.

    The /etc/aliases file is where the aliases are stored. The sendmail program consults this file when determining how to handle an incoming mail message. If it finds an entry in this file matching the target user in the mail message, it redirects the message to wherever the entry describes.

    Specifically there are three things that aliases allow to happen:

    1. They provide a shorthand or well-known name for mail to be addressed to in order to go to one or more persons.

    2. They can invoke a program with the mail message as the input to the program.

    3. They can send mail to a file.

  2. Demonstrate the common types of aliases

    usenet:     daph     # alias for a person
    admin:     daph,lee,     # alias for several people
    news:     :include:/home/news     # read recipients from file
    changefeed:     |/usr/local/lib/gup     # to invokes program
    complaints:     /var/log/complaints     # alias writes mail to file

  3. After modify the /etc/aliases, update the aliases file with:

    newaliases

Accepting Mail from Other Domains

  1. If we wish to configure virtual email hosting, the first thing we need to do is to convince sendmail that it should also accept mail for the domains that we are hosting.

  2. To stick with the default filename, if we wished to offer virtual hosting to the domain1.com.my and domain2.com, we would create a /etc/mail/local-host-names that looks like:

    domain1.com.my
    domain2.com

  3. When this is done, and assuming appropriate DNS records exist that point those domain names to our host, sendmail will accept mail messages for those domains as though they were destined for our real domain name.

  4. In your zone files of those new domain names, you should use real domain name’s MX mail server. Make a MX record like mail.domain1.com.my to domain1.com.my. Also, remember to make a A record for this mail.domain1.com.my to point to an IP address. Without this, sendmail (v8.9.x) will not deliver mail to the virtual domain.

Forwarding Virtual-hosted Mail

  1. Add forwarding terms in /etc/mail/virtusertable

  2. Possible entries in virtusertable with virtual hosting of domain1.com.my and domain2.com domains in local-host-names:

    1. User admin in virtual mail domain1.com.my to local user daph
      admin@domain1.com.my        daph

    2. User daph in virtual domains domain1.com.my to another domains:
      daph@domain1.com.my  daph@otherdomain.com

    3. Any mail to domain2.com are forwarded to daph@otherdomain.com
      @domain2.com      daph@otherdomain.com

    4. Any mail to domain2.com are forwarded to the same user in another domains otherdomain.com
      @domain2.com      $1@otherdomain.com

  3. Create the virtusertable database map with:

    makemap hash /etc/mail/virtusertable < /etc/mail/virtusertable

  4. In addition to the mail forwarding provided by aliases, sendmail allows individual users to define their own forwarding. The user defines her personal forwarding in the .forward file in her home directory. sendmail checks for this file after using the aliases file and before making final delivery to the user. If the .forward file exists, sendmail delivers the mail as directed by that file.

Sendmail Configuration Script

  1. Alternatively, you can configure your sendmail with this sendmail-install.5.5 script.

  2. tar -zxvf sendmail-install-5.5.tar.gz

  3. ./install-sendmail –c

  4. Follow the onscreen step by step wizard to configure your sendmail aliases, virtual user table, outgoing mail server, incoming mail server, sendmail for local network, server queue time and others.

Categories: Lesson, Linux, Server, Solution, Web Hosting.

Comment Feed

No Responses (yet)



Some HTML is OK

or, reply to this post via trackback.