How do I get 'mail' working again

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I get 'mail' working again

rachalmers

I’ve moved all my postfix binaries to /usr/local/bin and my configs etc to /usr/local/etc/postfix

However, because ‘mail’ is installed by Apple by default into /usr/bin/mail,  if I now type

mail robert

I get,

robert$ unknown: fatal: open /etc/postfix/main.cf: No such file or directory

Because of course, it’s now all in /usr/local/etc

What am I missing here? Everything works fine. Mail comes and goes from outside on the internet etc, but ‘mail’ has become inoperable because it’s still looking for Apple’s old cf files.


Does anyone have an idea on this. Is mail a link to postfix’s Sendmail maybe? If I just do
sendmail robert
I get no prompts or anything. Although, it does work.

thanks
Robert
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Luciano Mannucci
On Thu, 27 Dec 2018 12:19:34 +0000
Robert Chalmers <[hidden email]> wrote:

> I’ve moved all my postfix binaries to /usr/local/bin and my configs etc
> to /usr/local/etc/postfix
>
> However, because ‘mail’ is installed by Apple by default into /usr/bin/mail,
> if I now type
>
> mail robert
>
> I get,
>
> robert$ unknown: fatal: open /etc/postfix/main.cf: No such file or directory
You might whish to link -s /usr/local/etc/postfix /etc (postfix
installation does that if asked to).

Cheers,

Luciano.
--
 /"\                         /Via A. Salaino, 7 - 20144 Milano (Italy)
 \ /  ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
  X   AGAINST HTML MAIL    /  E-MAIL: [hidden email]
 / \  AND POSTINGS        /   WWW: http://www.lesassaie.IT/
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

rachalmers
Thanks Luciano,
It works - of course. I probably did realise that but being in Christmas mode … I forgot.

However, it’s kind of brute force really, and I’d hoped I could find a src for ‘mail’ and rebuild it to reflect my new setup.

ok. It’s reading everything fine now. Until the next time Apple updates to OS, and their version of postfix/mail overwrites everything in the postfix folders again.
I just hope the Apple version doesn’t overwrite everything in /usr/local/etc/postfix by following the link… Now that would be a disaster

cheers
Robert

> On 27 Dec 2018, at 12:53, Luciano Mannucci <[hidden email]> wrote:
>
> On Thu, 27 Dec 2018 12:19:34 +0000
> Robert Chalmers <[hidden email]> wrote:
>
>> I’ve moved all my postfix binaries to /usr/local/bin and my configs etc
>> to /usr/local/etc/postfix
>>
>> However, because ‘mail’ is installed by Apple by default into /usr/bin/mail,
>> if I now type
>>
>> mail robert
>>
>> I get,
>>
>> robert$ unknown: fatal: open /etc/postfix/main.cf: No such file or directory
> You might whish to link -s /usr/local/etc/postfix /etc (postfix
> installation does that if asked to).
>
> Cheers,
>
> Luciano.
> --
> /"\                         /Via A. Salaino, 7 - 20144 Milano (Italy)
> \ /  ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
>  X   AGAINST HTML MAIL    /  E-MAIL: [hidden email]
> / \  AND POSTINGS        /   WWW: http://www.lesassaie.IT/

Robert Chalmers
https://robert-chalmers.uk
[hidden email]
@R_A_Chalmers

Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Wietse Venema
In reply to this post by rachalmers
Robert Chalmers:
>
> I?ve moved all my postfix binaries to /usr/local/bin and my configs etc to /usr/local/etc/postfix

When you BUILT Postfix, you forgot this part from the INSTALL file:

4.6.1 - Postfix 3.0 and later

All Postfix configuration parameters can be changed by editing a Postfix
configuration file, except for one: the parameter that specifies the location
of Postfix configuration files. In order to build Postfix with a configuration
directory other than /etc/postfix, use:

    $ make makefiles config_directory=/some/where ...other arguments...
    $ make


Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

rachalmers

Sorry, when I said ‘moved’ I meant built with new install directories. As you point out below. 
However, ‘mail’ got lost after I removed the Apple default /etc/postfix directory. Apple’s default mail is built to look for /etc/postfix, so with the link now in place it’s working ok. mail thinks it’s looking at the default /etc/postfix directory.

I decided to build into /usr/local ..., because I got fed up with Apple installing its own rubbish postfix version over the top of my build every major upgrade.
Anyway, all is well for the moment.


-----
Robert Chalmers
https://robert-chalmers.uk
[hidden email]
@R_A_Chalmers


On 27 Dec 2018, at 1:17 pm, Wietse Venema <[hidden email]> wrote:

Robert Chalmers:

I?ve moved all my postfix binaries to /usr/local/bin and my configs etc to /usr/local/etc/postfix

When you BUILT Postfix, you forgot this part from the INSTALL file:

4.6.1 - Postfix 3.0 and later

All Postfix configuration parameters can be changed by editing a Postfix
configuration file, except for one: the parameter that specifies the location
of Postfix configuration files. In order to build Postfix with a configuration
directory other than /etc/postfix, use:

   $ make makefiles config_directory=/some/where ...other arguments...
   $ make


Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Benny Pedersen-2
In reply to this post by rachalmers
Robert Chalmers skrev den 2018-12-27 13:19:

> robert$ unknown: fatal: open /etc/postfix/main.cf: No such file or
> directory
>
> Because of course, it’s now all in /usr/local/etc

prefix is compiled in, so you cant just move binaries

> What am I missing here? Everything works fine. Mail comes and goes
> from outside on the internet etc, but ‘mail’ has become inoperable
> because it’s still looking for Apple’s old cf files.

uninstall postfix, recompile tarball with prefix /usr/local and remember
do not afterwards do a apple install of postfix, recompile new tarballs
with local prefix

> Does anyone have an idea on this. Is mail a link to postfix’s Sendmail
> maybe? If I just do
> sendmail robert
> I get no prompts or anything. Although, it does work.

i still miss a apple computer to test with, but i know the basic to do
it
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Viktor Dukhovni
My advice would be to keep the configuration directory as
/etc/postfix, but relocate all the binaries.  That way
the system provided /usr/sbin/sendmail will still work,
despite being an older version of Postfix.

> On Dec 27, 2018, at 6:29 PM, Benny Pedersen <[hidden email]> wrote:
>
> uninstall postfix, recompile tarball with prefix /usr/local and remember do not afterwards do a apple install of postfix, recompile new tarballs with local prefix

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

rachalmers

There seems to be some confusion here. Sorry.

The build of postfix works fine, including sendmail.
At build time, the root directory is set to /usr/local so everything gets installed in the right place at ‘make install’ time. Right where I want it. All good.

Now on the other hand. Apple puts its own version into its own location. There is no control over this. Every major OS upgrade puts it there into /etc and /usr.

My original post was about what to do about the program called ‘mail’ which by default - and can’t be changed - looks for /etc/postfix for the config files.

So on another suggestion I linked /usr/local/postfix into /etc which solves the problem for now.
All good.

Thanks for the help though

Robert





> On 27 Dec 2018, at 11:35 pm, Viktor Dukhovni <[hidden email]> wrote:
>
> My advice would be to keep the configuration directory as
> /etc/postfix, but relocate all the binaries.  That way
> the system provided /usr/sbin/sendmail will still work,
> despite being an older version of Postfix.
>
>> On Dec 27, 2018, at 6:29 PM, Benny Pedersen <[hidden email]> wrote:
>>
>> uninstall postfix, recompile tarball with prefix /usr/local and remember do not afterwards do a apple install of postfix, recompile new tarballs with local prefix
>
> --
>    Viktor.
>
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Wietse Venema
Robert Chalmers:
> My original post was about what to do about the program called ?mail? which by default - and can?t be changed - looks for /etc/postfix for the config files.
>

Tis is incorrect.

The mail program does not need /etc/postfix. The mail program
invokes a 'sendmail' program that is supplied by Apple, and that
program needs /etc/postfix.

Symlinking /etc/postfix -> /usr/local/etc/postfix creates a hybrid:

/usr/bin/mail, uses a hard-coded pathname to find
    -> Apple Postfix /usr/sbin/sendmail, uses your main.cf to find
        -> Your postdrop, uses your main.cf to find
            -> Your Postfix queue.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

rachalmers
Thanks,
Well, I was almost correct:-)
Mail looked for sendmail in /user/sbin which in turn, being the Apple version, looked for the /etc/postfix config files.

So I now:
1. Removed the sym link from /etc/postfix -> /user/local/etc/postfix
2. Moved /usr/sbin/sendmail to /usr/sbin/sendmail.OFF
3. Symlinked:  ln -s /usr/local/sbin/sendmail -> /usr/sbin/sendmail

And all works well and I don’t have to worry about wiping out my own postfix directories on the next upgrade.
I also turned off a few other Apple version postfix files in /usr/sbin

I only use mail to fire off messages about a couple of cron jobs that run nightly, so I don’t use it for anything else.

I just have to remember that after the nextApple upgrade... it will again replace my symlink to sendmail with its own sendmail. So I just have todo this bit again.

Which is why in the first place, I wanted to be able to just rebuild or configure ‘mail’

Oh well. Keeps me busy.





> On 28 Dec 2018, at 1:37 pm, Wietse Venema <[hidden email]> wrote:
>
> Robert Chalmers:
>> My original post was about what to do about the program called ?mail? which by default - and can?t be changed - looks for /etc/postfix for the config files.
>>
>
> Tis is incorrect.
>
> The mail program does not need /etc/postfix. The mail program
> invokes a 'sendmail' program that is supplied by Apple, and that
> program needs /etc/postfix.
>
> Symlinking /etc/postfix -> /usr/local/etc/postfix creates a hybrid:
>
> /usr/bin/mail, uses a hard-coded pathname to find
>    -> Apple Postfix /usr/sbin/sendmail, uses your main.cf to find
>    -> Your postdrop, uses your main.cf to find
>        -> Your Postfix queue.
>
>    Wietse
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Viktor Dukhovni


> On Dec 28, 2018, at 11:47 AM, Robert Chalmers <[hidden email]> wrote:
>
> Thanks,
> Well, I was almost correct:-)
> Mail looked for sendmail in /user/sbin which in turn, being the Apple version, looked for the /etc/postfix config files.
>
> So I now:
> 1. Removed the sym link from /etc/postfix -> /user/local/etc/postfix
> 2. Moved /usr/sbin/sendmail to /usr/sbin/sendmail.OFF
> 3. Symlinked:  ln -s /usr/local/sbin/sendmail -> /usr/sbin/sendmai

You don't need to do this, that will break every upgrade, and changing
it requires to disable Apple's system-integrity protection (at least
temporarily, and reboot to change it back and forth).

Instead, it is sufficient to:

Build your Postfix with binaries in /usr/local/{sbin,libexec/postfix,lib/postfix}, *but*
configuration in /etc/postfix.  Leave /usr/sbin/sendmail alone.

In /etc/postfix/main.cf, explicitly record your build parameters,
presumably something like:

        command_directory = /usr/local/sbin
        daemon_directory = /usr/local/libexec/postfix
        meta_directory = /usr/local/libexec/postfix
        shlib_directory = /usr/local/lib/postfix

With this, Apple's "/usr/sbin/sendmail" will invoke your "postdrop"
executable, and the interface between sendmail(1) and postdrop(1)
is stable enough to allow this to work.  The sendmail(1) program
writes a queue file via a pipe to postdrop(1), and postdrop(1)
will understand the queue file format, which is quite stable, and
when change does happen, it evolves in such a way that new Postfix
versions understand older formats.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Larry Stone
> On Dec 28, 2018, at 11:41 AM, Viktor Dukhovni <[hidden email]> wrote:
>
> You don't need to do this, that will break every upgrade, and changing
> it requires to disable Apple's system-integrity protection (at least
> temporarily, and reboot to change it back and forth).
>
> Instead, it is sufficient to:
>
> Build your Postfix with binaries in /usr/local/{sbin,libexec/postfix,lib/postfix}, *but*
> configuration in /etc/postfix.  Leave /usr/sbin/sendmail alone.
> …

Hmmm. Viktor, in the past, I thought you said it is sufficient to merely have both the Apple Postfix and your own Postfix have the same queue_directory. That’s how I have mine set up and it works the way I need it to work - /usr/sbin/sendmail (Apple’s sendmail) drops the file in queue_directory whereupon my locally built Postfix grabs it and sends it on its way. I have not made the four directories you mentioned the same.

--
Larry Stone
[hidden email]





Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Wietse Venema
Larry Stone:

> > On Dec 28, 2018, at 11:41 AM, Viktor Dukhovni <[hidden email]> wrote:
> >
> > You don't need to do this, that will break every upgrade, and changing
> > it requires to disable Apple's system-integrity protection (at least
> > temporarily, and reboot to change it back and forth).
> >
> > Instead, it is sufficient to:
> >
> > Build your Postfix with binaries in /usr/local/{sbin,libexec/postfix,lib/postfix}, *but*
> > configuration in /etc/postfix.  Leave /usr/sbin/sendmail alone.
> > ?
>
> Hmmm. Viktor, in the past, I thought you said it is sufficient to
> merely have both the Apple Postfix and your own Postfix have the
> same queue_directory. That?s how I have mine set up and it works
> the way I need it to work - /usr/sbin/sendmail (Apple?s sendmail)
> drops the file in queue_directory whereupon my locally built Postfix
> grabs it and sends it on its way. I have not made the four directories
> you mentioned the same.
>

Per Viktor's suggestion, Apple's /usr/sbin/sendmail will invoke
the locally-built /usr/local/sbin/postdrop, and the mail ends up
in the queue for the locally-built Postfix.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Viktor Dukhovni
In reply to this post by Larry Stone


> On Dec 28, 2018, at 4:59 PM, Larry Stone <[hidden email]> wrote:
>
> Hmmm. Viktor, in the past, I thought you said it is sufficient to merely have both the Apple Postfix and your own Postfix have the same queue_directory. That’s how I have mine set up and it works the way I need it to work - /usr/sbin/sendmail (Apple’s sendmail) drops the file in queue_directory whereupon my locally built Postfix grabs it and sends it on its way. I have not made the four directories you mentioned the same.

That should also work, it amounts to much the same thing.  Either
way the queue files end up in the same place.  And the daemons,
etc run from /usr/local.

--
        Viktor.

Reply | Threaded
Open this post in threaded view
|

Re: How do I get 'mail' working again

Peter Ajamian
In reply to this post by rachalmers
On 28/12/18 03:41, Robert Chalmers wrote:
> Sorry, when I said ‘moved’ I meant built with new install directories.
> As you point out below. 
> However, ‘mail’ got lost after I removed the Apple default /etc/postfix
> directory. Apple’s default mail is built to look for /etc/postfix, so
> with the link now in place it’s working ok. mail thinks it’s looking at
> the default /etc/postfix directory.

mail doesn't look for any particular postfix config at all.  mail is not
even a postfix command, it simply is a wrapper around /usr/bin/sendmail
which *is* provided by postfix and *does* look for the postfix config.


Peter