This is Bavaria, Germany!
Scenario: a linux-server which fetches mail from outside via fetchmail. Pipe mails through spamfiltering and viruschecking. There are no users on this system. All users are on another system in the LAN.
We get mails via fetchmail for these domains.
mail2.zdf:/etc/mail# cat /etc/fetchmailrc poll mail.gmx.de protocol POP3 user unicycler password xxxxxx to roland flush poll mail.hotmail.de protocol POP3 user monocycler password xxxxxx to roland flush poll mail.hotmail.de protocol POP3 user petra_miller password xxxxxx to petra flushThis means that fetchmail fetches mail via POP3-protocol and delivers it to a local user roland on this system (-> go to /etc/mail/aliases)
mymail:/etc/mail# cat aliases roland: roland@exchange.zdf petra: petra@exchange.zdf
But how shall sendmail send mails to exchange.zdf? Usually sendmail would ask DNS-servers for an mx-record. But not on this system, because we have a "smarthost" defined in sendmail.mc. Mails to roland@exchange.zdf would be delivered to smarthost which is in the internet.
But .zdf is a local domain unknown in the internet. So we have to redirect mails to exchange.zdf: get delivered directly to echange.zdf via smtp: this is done by "mailertable".
1. /etc/mail/sendmail.mc
define(`SMART_HOST',`smtprelay.t-online.de')dnl FEATURE(`mailertable', `hash /etc/mail/mailertable')dnl dnl # these MAILERs must be defined here because our lines in dnl # /etc/mail/mailertable tell sendmail to dnl # send via "smtp" (see nr. 2) MAILER(`local')dnl MAILER(`smtp')dnl |
2. /etc/mail/mailertable
Send all mail which is for mypost.we directly via smtp to 192.168.1.207
Square brackets mean: DON'T ask dns
mymail:/etc/mail# cat mailertable exchange.zdf smtp:[192.168.1.207]
There are mail-addresses in the internet which we also want to use internally. roland@zirndorf.de should NOT be delivered to the internet only to get back in a minute to our system. Mails for this user should be delivered internal.
This is called a virtual user in a virtual domain.
VIRTUSER_DOMAIN_FILE(`/etc/mail/virtual-domains')dnl FEATURE(`virtusertable', `hash /etc/mail/virtusertable')dnl |
For which domains shall be virtual users? Other domains will not be checked for virtual users, they get send directly to smarthost.
mail2.zdf:/etc/mail# cat virtual-domains
zirndorf.de zirndorf.net |
But these domains are not here. All mails for users in these domains get forwarded to local users via virtusertable.
roland@zirndorf.de roland roland@zirndorf.net roland postmaster@zirndorf.net edv richard@zirndorf.de richard-zirndorf@gmx.net |
An these local users (roland, edv) get mails delivered to a local account. If you want to forward these mails to another system -> /etc/mail/aliases. You can also deliver directly to another mailsystem like richard@zirndorf.de in the last line.
cd /var/log; >mail.log; echo hui | sendmail -v roland@zirndorf.de; sleep 2; cat mail.log