Sending Mail with Mailx, Sendmail and Postfix
The purpose of this document is to help users who want to setup customized email services on their local systems. However, most users should have little need to send an emails in such a way, say from a command line shell script or receiving emails as a server service from other hosts. Also, most users will only want to send emails and not receive them, hence using Mailx (nail) is much simpler by not setting up a mail server at all. Also, if you are just looking to receive pop/smtp mail, this document does not pertain to that either.
Sendmail is a professional mail server service allowing your system to handle incoming and outgoing mail requests. However, Sendmail is complicated to configure and overused for most users needs. If you are not looking to receive mail and are instead looking to simply send mail (i.e. from a script or whatever), you don't need sendmail. Just as you can send mail from an email client, you can send mail from your system without it using the internal site relays.
|Mailx (nail) Client Mailer|| |
|Sendmail Mail Server|| |
|PostFix Mail Server|| |
Instead you could use the "nail rpm" package which installs nail which will probably meet your needs in sending emails from scripts and such. Another example of not using sendmail would be setting up "thunderbird" with "us.ibm.com" as the outgoing mail smtp server.
- Switch to root (by typing su - or use the sudo command to open the nail.rc file:
- Add (somewhere in the middle of the file):
- Create a test email (use mailx not mail, it may be called nail too):
[quickm@host etc]$ mailx email@example.com
This is a test email using "nail", I hope this works because the reader
of this document will be really annoyed with me :-)
NOTE: type . and press enter key to end the body section of the text
Note: with nail => nail -s "Requested Report" -a report.txt firstname.lastname@example.org < /dev/null
RPM Package required (or build binary) : nail rpm package
Sendmail service allows users to send AND receive emails over various networks. Sendmail isn't needed for sending emails as you can use your own ISP or even setup nail for sending email right from your system. other options include procmail, mail.local, exim, and uucp. (not discussed). Note, this is unsupported and really should only serve as a reference overview.
Major files and tools
- system-switch-mail (Redhat and Fedora only)
- system-switch-mail-gnome - note, may update MTAs? (Redhat and Fedora only)
- /usr/share/comps/i386/comps.xml - list of rpm packages
- rpm -qi spamassassin
- make -C /etc/mail/
- chkconfig sendmail --level 35 on
- service sendmail restart
List of basic terms
- MTAs (Mail transfer agents) - sendmail, postfix, qmail
- MUAs (Mail user agents) - mail, Mozilla, elm
- MDAs (Mail delivery agents) - procmail, maildrop
- sendmail - Installs the most popular mail server of the same name
- imap - Supports IMAP and the POP incoming e-mail protocols
- sendmail-cf - templates; use to generate sendmail configuration file
- spamassassin - antispam program; start from sendmail or postfix
- squirrelmail - Installs a Web-based e-mail server
- postfix - Includes an alternative to sendmail
Additional Configurations Terms
- sendmail.cf - The main sendmail configuration file.
- sendmail.mc - A macro which you can edit and then generate a new sendmail.cf file.
- domaintable - Allows you to map different domains.
- helpfile - Supports help commands when you manage your mail server from the sendmail prompt.
- local-host-names - Allows you to add hostnames or aliases for your computer as a sendmail server.
- Makefile - Duh, Supports compiling the sendmail.mc file.
- spamassassin - spamblocker, configuration files that can help you minimize spam. If you want to configure it on locally received e-mail, add the following line to /etc/procmailrc:
- statistic - Collects statistics on sendmail usage in binary format. read it with 'mailstats'
- submit.cf - main outgoing sendmail configuration file.
- submit.mc - macro; used to generate new submit.cf file.
- trusted-users - Lists special users which can send e-mail without warnings.
- virtusertable - e-mail forwarding; if you have users outside your network who use sendmail.
Process when send mail starts:
1st reads sendmail.cf
then reads submit.cf
su -; cd /etc/mail
If you are located in EMEA, your SMTP server name is relay.uk.ibm.com
3 make from sendmail.mc
backup current sendmail.cf file
|It has been noticed that relays may not talk to other regions, in particular the relay.us.ibm.com relay fails to send emails to other regions (i.e. Europe ). Users may want to try us.ibm.com instead (in the US.)|
make -C /etc/mail or just type make
4 Start sendmail and test
service sendmail restart
5 set it to start at boot
chkconfig --level 35 sendmail on
[quickm@host etc]$ mailx email@example.com
This is a test email using "nail", I hope this works !
NOTE: type . and press enter key to end the body section of the text
What is Postfix? It is Wietse Venema's mailer that started life at IBM research as an alternative to the widely-used Sendmail program. "Postfix attempts to be fast, easy to administer, and secure. The outside has a definite Sendmail-ish flavor, but the inside is completely different. " - http://www.postfix.org/ .
For more information about this product, use their external website : http://www.postfix.org/
- Port 110
- the postfix package installed
- Install the postfix package either manually, via yum, or graphcial tool. In the Open Client for Linux Redhat / Fedora editions, it can be installed with:
yum install postfix
yum install system-switch-mail (Redhat / Fedora only)
- Next configure postfix for all interfaces:
(setup all interfaces)
[issue this]# postconf -e "inet_interfaces = all"
- If sendmail is running, turn it off
(turn off sendmail)
[issue this]# service sendmail stop
- Switch the MTA using the system-switch-mail command:
[issue this]# system-switch-mail
- Check the hosts file for a proper hostname configuration
(confirm "hostname" is ok)
cat /etc/hosts (127.0.0.1 myhost.subnet.net)
Look for a line which starts with 127.0.0.1 and contains your hostname after :
127.0.0.1 samba.fishkill.ibm.com samba
(example hostname being samba)
- Now Start the postfix service:
(start postfix, use restart, not start)
service postfix restart
- To set postfix to startup during boot up :
chkconfig --list postfix (setup if needed)
chkconfig --level 35 postfix on (turns it on)
chkconfig --list postfix
- Send an email to postfix
(try mailing to postfix)
mail -s `echo $USER` firstname.lastname@example.org < /etc/redhat-release
- Telnet to the mail port:
(telnet localhost 110)
[quickm@morocco quickm]$ telnet localhost 110
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
+OK POP3 localhost.localdomain v2003.83rh server ready
+OK User name accepted, password please
+OK Mailbox open, 0 messages
Connection closed by foreign host.
install fetchmail packages
create ~/.fetchmailrc with chmod 600