Section 4.5. Sending Email


4.5. Sending Email

By default, mail on Fedora Core 4 is handled by the sendmail program. sendmail can be configured to perform very complicated tasks, like running all the email for a company or an ISP. Entire books can (and have) been written about it. However, you're unlikely to want to make your LAMP server double as your mail server, and you're already likely to have a mail server. Some services on your LAMP server will generate email; for example, if a cron job fails, it will often email a description of its error to root@localhost, the root user's account's mailbox. That mail needs to be read, sometimes urgently, and it would be a pain to have to log in to your server to do so. The best approach is to ensure that all mail that goes to your Web server is sent to an address at which the system administrator can read it. We'll set up the Web server so that all the mail it receives is forwarded automatically to another email address.

4.5.1. The aliases File

Mail direction is controlled by the file /etc/aliases, which is shown below.

/etc/aliases

 # #  Aliases in this file will NOT be expanded in the header from #  Mail, but WILL be visible over networks or from /bin/mail. # #       >>>>>>>>>>      The program "newaliases" must be run after #       >> NOTE >>      this file is updated for any changes to #       >>>>>>>>>>      show through to sendmail. # # Basic system aliases -- these MUST be present. mailer-daemon:  postmaster postmaster:     root # General redirections for pseudo accounts. bin:            root daemon:         root adm:            root … marketing:      postmaster sales:          postmaster support:        postmaster # trap decode to catch security attacks decode:         root # Person who should get root's mail #root:          marc 

Each line in this file is an email alias; the line postmaster: root means "if mail comes to the postmaster account, put it in root's mailbox." By default, Fedora's aliases file ensures that mail for all the "system" accounts on the machine (i.e., all the accounts that the computer creates, rather than the ones that you create) goes to root's mailbox. This is very useful, because then, all you have to do is ensure that the mail that's sent to root ends up in the administrator's mailbox. This is a two-step process. First, record in the aliases file that root's mail should go to the administrator's mailbox. To do so, uncomment the last line in /etc/aliases, and change marc to the administrator's email address.

/etc/aliases (excerpt)

 # Person who should get root's mail root:          kermit@myisp.net 

Second, tell sendmail that the aliases file has changed by running the command newaliases:

[kermit@swinetrek ~]$ su Password: [root@swinetrek kermit]# newaliases /etc/aliases: 77 aliases, longest 16 bytes, 785 bytes total [root@swinetrek kermit]# exit exit [kermit@swinetrek ~]$ 

That's all that's required. From now on, any mail that's sent to root by any cron jobs (or similar) on your Web server will end up in your mailbox. If you've created additional accounts on your server (say, for individual system administrators), then you may wish also to add those accounts to /etc/aliases, making them forward their mail to root or other email addresses. Remember to run newaliases after you make the change.

/etc/aliases (excerpt)

 # Person who should get root's mail root:          kermit@myisp.net kermit:        root gonzo:         gonzo@myisp.net fozzie:        fozzie@myisp.net 




Run Your Own Web Server Using Linux & Apache
Run Your Own Web Server Using Linux & Apache
ISBN: 0975240226
EAN: 2147483647
Year: 2006
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net