Sendmail is a mail transfer agent (MTA) used to route and deliver email over the Internet. Originally developed in the early 1980s, Sendmail was one of the most widely used email routing programs, especially on UNIX and Linux systems. It handles the process of sending email from one server to another, often over the Simple Mail Transfer Protocol (SMTP).
- MTA Functionality: Sendmail acts as a bridge to move mail from the sender’s system to the recipient’s mail server.
- Highly Configurable: It allows complex configurations for routing email, filtering, and supporting multiple domains.
- Protocols Supported: It primarily uses SMTP for email delivery but can also support other protocols as needed.
- Mail Filtering: Sendmail allows the use of Milter (Mail Filter) to integrate custom email filtering tools for security and anti-spam measures.
- Scalability: Suitable for both small and large-scale email systems.
- Compatibility: Works well with various UNIX and Linux distributions.
Sendmail’s configuration is generally stored in a file located at /etc/mail/sendmail.cf
, though it is not typically edited directly due to its complexity. Instead, the configuration is often generated using a simpler sendmail.mc
macro file, which is then processed to produce the sendmail.cf
.
- Install Sendmail: Use your package manager to install Sendmail (e.g.,
sudo apt-get install sendmail
on Debian-based systems).
- Edit
sendmail.mc
: Modify the sendmail.mc
file to suit your needs.
- Generate
sendmail.cf
: Use the m4
macro processor to generate the sendmail.cf
file from sendmail.mc
.m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
- Restart Sendmail: Apply the changes by restarting the Sendmail service.
sudo systemctl restart sendmail
- Email Servers: Sendmail is used to set up mail servers that can send and receive email for a domain.
- Mail Relays: It can act as a mail relay between different servers.
- Email Forwarding and Aliasing: Sendmail allows the creation of aliases and forwarding rules.
- Corporate Email Systems: Often used in enterprise environments for internal and external email communications.
- User Submission: An email is submitted via a client, often using a Mail User Agent (MUA) like Thunderbird or mutt.
- Sendmail Processing: The Sendmail MTA processes the email and determines how to route it.
- Message Queuing: If the destination is not immediately reachable, Sendmail will queue the message for later delivery.
- Final Delivery: Sendmail communicates with the recipient’s MTA to deliver the message.
- Log Files: Check
/var/log/mail.log
or /var/log/maillog
for Sendmail logs.
- Mail Queue: Use
mailq
to view the mail queue and sendmail -q
to process the queue.
- Testing Configuration: Use
sendmail -bt
to test and debug the configuration.
- Postfix: A more modern and secure alternative to Sendmail with simpler configuration.
- Exim: Another alternative that offers more flexible configurations.
- qmail: Known for its security and efficiency.