The following section covers more involved topics such as mail configuration and setting up mail for your entire domain.
Out of the box, you should be able to send email to external hosts as long as you have set up /etc/resolv.conf or are running your own name server. If you would like to have mail for your host delivered to that specific host, there are two methods:
Run your own name server and have your own domain. For example, FreeBSD.org
Get mail delivered directly to your host. This is done by delivering mail directly to the current DNS name for your machine. For example, example.FreeBSD.org.
Regardless of which of the above you choose, in order to have mail delivered directly to your host, you must have a permanent (static) IP address (no dynamic PPP dial-up). If you are behind a firewall, it must pass SMTP traffic on to you. If you want to receive mail at your host itself, you need to be sure of one of two things:
Make sure that the MX record in your DNS points to your host's IP address.
Make sure there is no MX entry in your DNS for your host.
Either of the above will allow you to receive mail directly at your host.
Try this:
# hostname example.FreeBSD.org # host example.FreeBSD.org example.FreeBSD.org has address 204.216.27.XX
If that is what you see, mail directly to <yourlogin@example.FreeBSD.org> should work without problems.
If instead you see something like this:
# host example.FreeBSD.org example.FreeBSD.org has address 204.216.27.XX example.FreeBSD.org mail is handled (pri=10) by hub.FreeBSD.org
All mail sent to your host (example.FreeBSD.org) will end up being collected on hub under the same username instead of being sent directly to your host.
The above information is handled by your DNS server. The DNS record that carries mail routing information is the Mail eXchange entry. If no MX record exists, mail will be delivered directly to the host by way of its IP address.
The MX entry for freefall.FreeBSD.org at one time looked like this:
freefall MX 30 mail.crl.net freefall MX 40 agora.rdrop.com freefall MX 10 freefall.FreeBSD.org freefall MX 20 who.cdrom.com
As you can see, freefall had many MX entries. The lowest MX number is the host that ends up receiving the mail in the end while the others will queue mail temporarily if freefall is busy or down.
Alternate MX sites should have separate Internet connections from your own in order to be the most useful. Your ISP or other friendly site should have no problem providing this service for you.
In order to set up a ``mailhost'' (a.k.a., mail server) you need to have any mail sent to various workstations directed to it. Basically, you want to ``hijack'' any mail for your domain (in this case *.FreeBSD.org) and divert it to your mail server so your users can check their mail via POP or directly on the server.
To make life easiest, a user account with the same username should exist on both machines. Use adduser to do this.
The mailhost you will be using must be the designated mail exchange for each workstation on the network. This is done in your DNS configuration like so:
example.FreeBSD.org A 204.216.27.XX ; Workstation MX 10 hub.FreeBSD.org ; Mailhost
This will redirect mail for the workstation to the mailhost no matter where the A record points. The mail is sent to the MX host.
You cannot do this yourself unless you are running a DNS server. If you are not, or cannot, run your own DNS server, talk to your ISP or whoever does your DNS for you.
If you're doing virtual email hosting, the following information will come in handy. For the sake of an example, we will assume you have a customer with their own domain, in this case customer1.org and you want all the mail for customer1.org sent to your mailhost, which is named mail.myhost.com. The entry in your DNS should look like this:
customer1.org MX 10 mail.myhost.com
You do not need an A record if you only want to handle email for the domain.
Note: Be aware that this means pinging customer1.org will not work unless an A record exists for it.
The last thing that you must do is tell sendmail on your mailhost what domains and/or hostnames it should be accepting mail for. There are a few different ways this can be done. Either of the following will work:
Add the hosts to your /etc/sendmail.cw file if you are using the FEATURE(use_cw_file). If you are using sendmail 8.10 or higher, the file is /etc/mail/local-host-names.
Add a Cwyour.host.com line to your /etc/sendmail.cf or /etc/mail/sendmail.cf if you are using sendmail 8.10 or higher.
For questions about FreeBSD, e-mail
<questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.