Выбрать главу

@fedorabook.com chris

The last entry will redirect all mail to the fedorabook.com domain to the local user chris , except for mail addressed to joe@fedorabook.com or frank@fedorabook.com (because they are listed first, and the file is processed in the sequence given).

Like /etc/mail/sendmail.mc , the virtusertable file must be processed before it is used:

# cd /etc/mail

# make

7.6.1.6. Configuring Masquerading

sendmail includes masquerading capability, which enables outbound mail to be modified so that it looks like it came from another system. This is commonly used to remove hostname information from the email address. To configure bluesky.fedorabook.com so that outbound mail appears to be from user @fedorabook.com instead of user @bluesky.fedorabook.com , locate the MASQUERADE_AS line in /etc/mail/sendmail.mc :

dnl # The following example makes mail from this host and any additional

dnl # specified domains appear to be sent from mydomain.com

dnl #

dnl MASQUERADE_AS(\Qmydomain.com')dnl

Uncomment the MASQUERADE_AS line and replace mydomain.com with the domain name you wish to use:

MASQUERADE_AS(\Q fedorabook.com ')dnl

7.6.2. How Does It Work?

Fedora's email system, like most others, is divided into three parts:

mail transport agent (MTA)

Transports mail between systems. sendmail is the default MTA.

mail delivery agent (MDA)

Delivers mail to local users, optionally performing filtering or sending vacation replies ("Jane is away from the office until Monday; she will read and reply to your mail when she returns"). Fedora uses procmail in this role.

mail user agent (MUA)

The email client that interacts with the user. A Fedora user can choose from many different MDAs, including Evolution, Thunderbird, SquirrelMail, and the text-based mail command.

Originally written when a wide range of email transportation schemes were in use, sendmail is designed to route mail through and between these different systems, each with their own address format and message queuing system. Because of this heritage, sendmail has a sophisticated and complex configuration system, but many of the configuration options are not used for Internet email servers.

sendmail is now used almost exclusively with the Simple Mail Transport Protocol (SMTP), which is a human-readable transfer protocol that uses TCP/IP connections on port 25. You can use telnet to connect to an SMTP server and manually send mail if you want:

$ telnet concord2.proximity.on.ca smtp

Trying 127.0.0.1...

Connected to concord2.proximity.on.ca (127.0.0.1).

Escape character is '^]'.

220 concord2.proximity.on.ca ESMTP Sendmail 8.13.5/8.13.5; Thu, 2 Mar 2006 13:07:11 -0500

EHLO fedorabook.com

250- concord2.proximity.on.ca Hello concord8.proximity.on.ca [127.0.0.1], pleased to meet you

250-ENHANCEDSTATUSCODES

250-PIPELINING

250-8BITMIME

250-SIZE

250-DSN

250-ETRN

250-AUTH DIGEST-MD5 CRAM-MD5

250-DELIVERBY

250 HELP

MAIL From: chris@fedorabook.com

250 2.1.0 chris@fedorabook.com... Sender ok

RCPT To: chris@concord2.proximity.on.ca

250 2.1.5 chris@concord2.proximity.on.ca... Recipient ok

DATA

354 Enter mail, end with "." on a line by itself

Subject: Greetings!Date: Thu, Mar 2006 12:08:11 -0500

Hi there -- just dropping you a quick note viatelnet. Hope your day is going well.

-Chris .

250 2.0.0 k22I7BTo016133 Message accepted for delivery

QUIT

221 2.0.0 concord2.proximity.on.ca closing connection

Notice the blank line separating the email headers from the message bodyjust like HTTP transfers. The HTTP format is derived from the email format.

You can also send mail by sending it to the standard input of a sendmail process:

$ /usr/bin/sendmail chris@concord2.proximity.on.caSubject: Test II

Did you remember to renew the domain registration?If not, please take care of this before next Tuesday.[Ctrl-D]

Outbound mail is queued in /var/spool/mqueue /. Inbound mail is delivered via procmail to users' mailboxes in /var/spool/mail/ . The mailboxes are simply text files containing all of the messages concatenated end to end; this format is sometimes called mbox format .

The /etc/mail/sendmail.mc file used for configuration is an m4 macro file. It is interpreted by the m4 command using files in /usr/share/sendmail-cf/m4/ to build /etc/mail/sendmail.cf . While it is possible to construct the sendmail.cf file by hand, it's typically eight times as long as the sendmail.mc file and uses a very cryptic structure. Here's a snippet:

R< > $+             $: < > < $1 <> $&h >   nope, restore +detail

R< > < $+ <> + $* > $: < > < $1 + $2 >     check whether +detail

R< > < $+ <> $* >   $: < > < $1 >          else discard

R< > < $+ + $* > $*    < > < $1 > + $2 $3  find the user part

R< > < $+ > + $*    $#local $@ $2 $: @ $1  strip the extra +

R< > < $+ >         $@ $1                  no +detail

R$+                 $: $1 <> $&h           add +detail back in

Most system administrators would much rather deal with sendmail.mc than sendmail.cf .

7.6.3. What About...

7.6.3.1. ...using an alternate MTA?