On 2006-08-25 18:40, eoghan <[EMAIL PROTECTED]> wrote:
>On 25 Aug 2006, at 18:35, Giorgos Keramidas wrote:
>>On 2006-08-25 16:00, eoghan <[EMAIL PROTECTED]> wrote:
>>> Hello
>>> Im using sylpheed for my mail (its work mail). Having some issues
>>> sending from their smtp server to non-work accounts.
>>> I have sendmail installed but I have never used it before and am
>>> wondering if I can use this through my local machine to send my
>>> mail?
>> Yes, of course :-)
>> This is what I usually do.
> Heh, thanks. I guess youre saying I should have said: how would i go
> about doing this...

If someone was to re-write a step by step guide for Sendmail on FreeBSD,
it would take far more than a single email response.

You should definitely start by reading, at least, the following:


For available configuration options and the functionality they
implement, you can also look at: /usr/share/sendmail/cf/README

The Sendmail FAQ is also a valuable resource, and it is available online
at: http://www.sendmail.org/faq/index.html

In general, what you have as a goal is something that works like this:

    +--------------+      related            +------------------+
    |              |      messages           |                  |
    |   Sendmail   |  ====================>  |  Company's Mail  |
    |              |                         |     Gateway      |
    |   Running    |                         |                  |
    |     as       |                         +------------------+
    |   a local    |
    |     MTA      |
    |              |  ==========.
    |              |            | other      +------------------+
    +--------------+            | messages   |                  |
                                |            |   Mail Gateway   |
                                `=========>  |     of your      |
                                             |     Internet     |
                                             |     Provider     |
                                             |                  |

This is very easy to do in FreeBSD.  You just have to run `make' once in
the `/etc/mail' directory.  This will create two files, called:


where `HOSTNAME' is your local host name.  You can configure Sendmail,
by following the instructions in the Handbook, the help in the README
file of the Sendmail macros, at `/usr/share/sendmail/cf/README', and
making configuration changes to `HOSTNAME.mc'.

You can direct all outgoing email from `localhost' to the mail gateway
of your ISP, by reading the comments in `/etc/mail/HOSTNAME.mc' and
enabling the `SMART_HOST' feature.

Extra bonus points, if you don't want company email to pass through the
MTA of your ISP, if you set up a `mailertable' entry to direct all
company-related email to the mail gateway of your company, you can use
the `mailertable' feature.  Note that some ISPs do not allow outgoing
connections to port 25 of any random host, so this may not be always
possible though.

Attached below are two descriptions of the steps I took to set up
Sendmail, from two of my older posts to the list.  See if these are of
any help too.

The second one describes the configuration I use on my workstation at
work, to do something similar to the "two-way output" (work email to the
email gateway of work, all the rest to the default mail gateway) which
is shown in the ASCII-diagram above.


Date: Fri, 26 Mar 2004 07:34:45 +0200
From: Giorgos Keramidas <[EMAIL PROTECTED]>
To: David Bear
Cc: freebsd-questions@freebsd.org
Subject: Re: sendmail local mta mode only
References: <[EMAIL PROTECTED]>

On 2004-03-25 19:24, David Bear <[EMAIL PROTECTED]> wrote:
> Not sure how to phrase this to limit the number of google hits ..
> I would like to run the stock sendmail freebsd has as a local MTA
> only... ie I don't want to listening on ANY real/public interface for
> mail.  I do want it to handle delivery of local messages to local
> accounts -- and handle sending messages destined for external systems.

I think that what you need is something similar to my setup at home,
where sendmail doesn't listen on any public interfaces:

    $ sockstat | { read head ; echo "$head"; grep :25; }
    root     sendmail   458   4  tcp4          *:*

Delivery of local messages is handled nicely by the "submit" daemon
that I run, and mail submitted by local programs into the clientmqueue
is pushed along by an msp_queue daemon:

    $ ps xa | grep -v grep | grep sendmail
      458  ??  Ss     0:01.17 sendmail: accepting connections (sendmail)
      461  ??  Is     0:00.09 sendmail: Queue [EMAIL PROTECTED]:10:00 for 
/var/spool/clientmqueue (sendmail)

To set things up like this, I have the following settings in my
/etc/rc.conf file:

    # Do not run the sendmail inbound daemon to listen on any interfaces.
    # Start a localhost-only MTA for mail submission.
    sendmail_submit_flags="-L smtpd -bd -q30m 
    # Dequeue stuck clientmqueue mail every 30 minutes.
    sendmail_msp_queue_flags="-L mailq -Ac -q30m"

There are also the following configuration files for Sendmail in my
/etc/mail directory:

    -rw-r--r--  1 root  wheel   1612 Jan  7 01:41 gothmog.mc
    -rw-r--r--  1 root  wheel    849 Apr 11  2003 gothmog.submit.mc

The hostname is "gothmog.gr", which means that the Makefile in
/etc/mail will automagically look for exactly these two names when
trying to build the sendmail.cf and submit.cf configuration files,
after root runs:

    # cd /etc/mail
    # make
    # make install

The contents of these two files have been copied from freebsd.mc and
freebsd.submit.mc, respectively.  The modifications that are required
to make them "just work" are very minimal -- most of the time, all you
need is to add *one* line to freebsd.mc stating your ISP's outgoing
mail gateway, i.e. something similar to:

    define(`SMART_HOST', `mail.example.net')

and you're set to go.

Before making any modifications to freebsd.mc and freebsd.submit.mc,
you should probably copy them to their local equivalents, since the
'freebsd*.mc' files are overwritten every time you update your FreeBSD
system to a newer version.

Summing it all up, the installation & configuration process of
Sendmail for your type of setup should include the following steps:

    1.  As root, working in /etc/mail, copy the files freebsd.mc and
freebsd.submit.mc to `hostname`.mc and `hostname`.submit.mc,
respectively,  replacing `hostname` with your local host name.

    2.  If you are supposed to use an outgoing mail gateway (i.e. your
ISP's mail gateway) edit `hostname`.mc and add the line:

        define(`SMART_HOST', `mail.example.net')

    3.  While still working in /etc/mail, update sendmail.cf and
submit.cf, from your new .mc files:

        # make
        # make install

    4.  Edit your /etc/rc.conf file:

        a.  Comment out or remove all instances of sendmail_xxx
options you might have there.  My suggestion is to either comment them
out or make a backup copy of the entire file, before making any
modifications.  This way you can quickly revert any changes you make,
if you happen to find out they don't suit your needs.

        b.  Add the following lines (short descriptions can be found
in the file /etc/defaults/rc.conf and more detailed explanations of
what they do is included in the rc.conf(5) manpage):

           sendmail_submit_flags="-L smtpd -bd -q30m 
           sendmail_msp_queue_flags="-L mailq -Ac -q30m"

    5.  Restart Sendmail, running as root in /etc/mail:

        # make restart

        While running this last step, you might want to keep a window
open with a `tail -f' command running on /var/log/maillog, watching
for reports of any unexpected errors or failures.  If all is fine, you
should see something like this fly by:

Mar 26 07:22:06 gothmog smtpd[458]: restarting /usr/sbin/sendmail due to signal
Mar 26 07:22:06 gothmog mailq[461]: restarting /usr/sbin/sendmail due to signal
Mar 26 07:22:06 gothmog smtpd[3892]: starting daemon (8.X.Y): [EMAIL 
Mar 26 07:22:06 gothmog mailq[3895]: starting daemon (8.X.Y): [EMAIL 

- Giorgos


Date: Sat, 4 Sep 2004 04:11:19 +0300
From: Giorgos Keramidas <[EMAIL PROTECTED]>
To: chip
Cc: freebsd-questions@freebsd.org
Subject: Re: sendmail setup
References: <[EMAIL PROTECTED]>

On 2004-09-03 16:57, [EMAIL PROTECTED] wrote:
> Could someone please just explain what is needed to make it send mail
> out to the world from just one machine on the lan. It can't be as hard
> as it appears to be.

The setup of my workstation at work to forward outgoing email to the
mail gateway available to all the machines of the internal network is
the following:

Sendmail options in rc.conf

The following options are in my `/etc/rc.conf' file:

    % grep sendmail /etc/rc.conf
    sendmail_submit_flags="-L sm-mta -bd -q5m 
    sendmail_msp_queue_flags="-L sm-msp -Ac -q30m"

The two enabled sendmail processes have the following function:

        This listens on and allows local processes (including
        the msp_queue process) to post messages.  It uses sendmail.cf as
        its configuration file and can forward all your outgoing messages
        to the mail gateway of your LAN (see the SMART_HOST option below).

        This sendmail process scans periodically the messages in the queue
        /var/spool/clientmqueue and makes sure they don't get stuck there.

The genericstable address rewriting rules

The file /etc/mail/genericstable contains the following:

    % cat /etc/mail/genericstable

Thus, all messages posted by user `keramida' on my workstation will have
their address rewritten to [EMAIL PROTECTED], which is certainly
more useful to the rest of the world than my internal workstation address.

The mailertable message routing table

I want all my company email routed through our VPN to the internal email
server, instead of travelling through the Internet to reach the same
server's external interface.  To accomplish this I use a mailertable with
the following entries:

    % cat /etc/mail/mailertable
    .company.com                        smtp:internal-mx.company.com
    company.com                         smtp:internal-mx.company.com

Custom envelope from addresses

Some times I run scripts under my uid that want to "fake" their envelope
from address.  Thus, I have created a file called /etc/mail/trusted-users
with a list of usernames that are allowed to set their envelope from
address with sendmail -f [EMAIL PROTECTED] without having a warning added
automagically by Sendmail in their header:

    % cat /etc/mail/trusted-users

The local hostnames

The file local-host-names as you already mentioned contains the list of
hostnames that my workstation should consider `local' and attempt to
deliver to a local user:

    % cat /etc/mail/local-host-names

I've added both the `internal-host' and `internal-host.internal.domain'
names, in case some locally running program tries to send mail using only
the hostname and not the fully qualified domain name of the workstation in
the local LAN.

The hostname.mc file

The Makefile in /etc/mail will look for a file called `hostname.mc' where
hostname is the short host name of your machine and use that as the source
for generating `sendmail.cf'.  If this file does not exist `freebsd.mc' is
copied to `hostname.mc' and the rest of the Makefile works as before.

The differences of my hostname.mc file from the freebsd.mc installed by
FreeBSD 6.0-CURRENT are:

    +FEATURE(genericstable, `hash -o /etc/mail/genericstable')
    -dnl define(`SMART_HOST', `your.isp.mail.server')
    +define(`SMART_HOST', `smtp.internal.domain')
     define(`confCW_FILE', `-o /etc/mail/local-host-names')
    +define(`confCT_FILE', `-o /etc/mail/trusted-users')
    -DAEMON_OPTIONS(`Name=IPv6, Family=inet6, Modifiers=O')

After what I wrote above the changes and their reasoning should be easy to
understand, except these few lines:


    -DAEMON_OPTIONS(`Name=IPv6, Family=inet6, Modifiers=O')

The first one is to make sure that all email sent from my workstation (or
forwarded from my workstation, in case I enable an internal SMTP server
later) will use @company.com addresses.

The second one is because I've removed IPv6 support from my kernel and I
don't like having Sendmail bother me about failed IPv6 connection attempts.

The Final Steps

*   Make sure you don't have different map types defined in your
    hostname.mc and in the Makefile of `/etc/mail' (i.e. a hardwired map
    type of `btree' in hostname.mc for the access.db table and a default
    map type of `hash' in Makefile).

*   Update the generated files of /etc/mail:

        # cd /etc/mail
        # make && make install && make restart

*   That's all.

freebsd-questions@freebsd.org mailing list
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to