This section covers more involved topics such as mail configuration and setting up mail for an entire domain.
Out of the box, one can send email to external hosts as
	long as /etc/resolv.conf is configured or
	the network has access to a configured DNS
	server.  To have email delivered to the MTA
	on the FreeBSD host, do one of the following:
Run a DNS server for the domain.
Get mail delivered directly to the FQDN for the machine.
In order to have mail delivered directly to a host, it must have a permanent static IP address, not a dynamic IP address. If the system is behind a firewall, it must be configured to allow SMTP traffic. To receive mail directly at a host, one of these two must be configured:
Either of the above will allow mail to be received directly at the host.
Try this:
#hostnameexample.FreeBSD.org#host example.FreeBSD.orgexample.FreeBSD.org has address 204.216.27.XX
In this example, mail sent directly to
	<yourlogin@example.FreeBSD.org>
	should work without problems, assuming
	Sendmail is running correctly on
	example.FreeBSD.org.
For this example:
#host example.FreeBSD.orgexample.FreeBSD.org has address 204.216.27.XX example.FreeBSD.org mail is handled (pri=10) by nevdull.FreeBSD.org
All mail sent to example.FreeBSD.org will
	be collected on hub under the same
	username instead of being sent directly to your host.
The above information is handled by the DNS server. The DNS record that carries mail routing information is the MX 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
freefall had many
	MX entries.  The lowest
	MX number is the host that receives mail
	directly, if available.  If it is not accessible for some
	reason, the next lower-numbered host will accept messages
	temporarily, and pass it along when a lower-numbered host
	becomes available.
Alternate MX sites should have separate Internet connections in order to be most useful. Your ISP can provide this service.
When configuring a MTA for a network, any mail sent to hosts in its domain should be diverted to the MTA so that users can receive their mail on the master mail server.
To make life easiest, a user account with the same username should exist on both the MTA and the system with the MUA. Use adduser(8) to create the user accounts.
The MTA must be the designated mail exchanger for each workstation on the network. This is done in theDNS configuration with an MX record:
example.FreeBSD.org A 204.216.27.XX ; Workstation MX 10 nevdull.FreeBSD.org ; Mailhost
This will redirect mail for the workstation to the MTA no matter where the A record points. The mail is sent to the MX host.
This must be configured on a DNS server. If the network does not run its own DNS server, talk to the ISP or DNS provider.
The following is an example of virtual email hosting.
	Consider a customer with the domain customer1.org, where all
	the mail for customer1.org should be
	sent to mail.myhost.com.  The
	DNS entry should look like this:
customer1.org MX 10 mail.myhost.com
An A record is
	not needed for customer1.org in order to
	only handle email for that domain.  However, running
	ping against customer1.org will not
	work unless an A record exists for
	it.
Tell the MTA which domains and/or hostnames it should accept mail for. Either of the following will work for Sendmail:
Add the hosts to
	    /etc/mail/local-host-names when
	    using the FEATURE(use_cw_file).
Add a Cwyour.host.com line to
	    /etc/sendmail.cf.
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
    documentation may be
    sent to <freebsd-questions@FreeBSD.org>.
    Send questions about this document to <freebsd-doc@FreeBSD.org>.