| 0 comments ]

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.

Topics Discussed In This Document
Mailx (nail) Client Mailer
  • Send email from your system using internal relays _(recommended)_
Sendmail Mail Server
  • Compile and configure a complicated mail server on your system
PostFix Mail Server
  • Configure an alternative mail server to sendmail
Mailx / nail instead of sendmail

Mailx / nail instead of sendmail


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.

Steps:

  1. Switch to root (by typing su - or use the sudo command to open the nail.rc file:
    vi /etc/nail.rc
  2. Add (somewhere in the middle of the file):
    set smtp=us.ibm.com
    set from=intranetID@us.ibm.com


  3. Create a test email (use mailx not mail, it may be called nail too):
    [quickm@host etc]$ mailx mquick@us.ibm.com
    Subject: test

    This is a test email using "nail", I hope this works because the reader
    of this document will be really annoyed with me :-)

    .

    Cc:

NOTE: type . and press enter key to end the body section of the text
Note: with nail => nail -s "Requested Report" -a report.txt user@host.com < /dev/null

RPM Package required (or build binary) : nail rpm package

/etc/nail.rc
/usr/bin/mailx
/usr/share/doc/nail-12.1
/usr/share/doc/nail-12.1/AUTHORS
/usr/share/doc/nail-12.1/COPYING
/usr/share/doc/nail-12.1/ChangeLog
/usr/share/doc/nail-12.1/INSTALL
/usr/share/doc/nail-12.1/README
/usr/share/doc/nail-12.1/TODO
/usr/share/man/man1/mailx.1.gz




Sendmail

Mail Services - Sendmail mail server configuration


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:
  • INCLUDERC=/etc/mail/spamassassin/spamassassin-default.rc
  • 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
/usr/share/sendmail-cf
/etc/mail

Setting up the basic sendmail feature at IBM:

1

su -; cd /etc/mail

2
Modify '/etc/mail/sendmail.mc'.
Change: define(`SMART_HOST',`[your.relay.machine.ip]')
define(`SMART_HOST',`relay.us.ibm.com')

For Outgoing mail (SMTP) server enter a mail server as follows:

If you are located in EMEA, your SMTP server name is relay.uk.ibm.com
If you are located in EMEA, your SMTP server name is relay.de.ibm.com
If you are located anywhere else (e.g. US, Canada, AP, etc.), your SMTP server name is relay.us.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

6 Testing:

[quickm@host etc]$ mailx testemail@host.com
Subject: test
This is a test email using "nail", I hope this works !
.

Cc:

NOTE: type . and press enter key to end the body section of the text


PostFix

Postfix Mail server -sendmail replacement


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/

Configuration etc.

  • Port 110
  • /etc/postfix/main.cf
  • /var/log/maillog
  • the postfix package installed

Generic configuration steps

  1. 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)


  2. Next configure postfix for all interfaces:
    (setup all interfaces)
    [issue this]# postconf -e "inet_interfaces = all"


  3. If sendmail is running, turn it off
    (turn off sendmail)
    [issue this]# service sendmail stop
  4. Switch the MTA using the system-switch-mail command:
    [issue this]# system-switch-mail


  5. 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)

  6. Now Start the postfix service:
    (start postfix, use restart, not start)
    service postfix restart
  7. 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


Testing postfix .

  1. Send an email to postfix
    (try mailing to postfix)
    mail -s `echo $USER` root@myhost.subnet.net < /etc/redhat-release
  1. Telnet to the mail port:
    (telnet localhost 110)
    [quickm@morocco quickm]$ telnet localhost 110
    Trying 127.0.0.1...
    Connected to localhost.localdomain (127.0.0.1).
    Escape character is '^]'.
    +OK POP3 localhost.localdomain v2003.83rh server ready
    USER
    +OK User name accepted, password please
    PASS
    +OK Mailbox open, 0 messages
    QUIT
    +OK Sayonara
    Connection closed by foreign host.

OPTIONAL:

install fetchmail packages
create ~/.fetchmailrc with chmod 600

0 comments

Post a Comment