Don't use hardcoded sendmail paths #34

Closed
goblin opened this Issue Jun 26, 2013 · 9 comments

Projects

None yet

4 participants

@goblin
goblin commented Jun 26, 2013

Why don't you just use the sendmail that's in $PATH?

I happen to use msmtp for outgoing mail and exim for local delivery... The way you've done it is it'll try to use exim (because that's what /usr/sbin/sendmail is symlinked to), and fail.

Also my msmtp is in /usr/bin not /usr/sbin.

@drewr
Owner
drewr commented Jun 26, 2013

I guess the short answer is that historically there's no way to predict where sendmail will live. It used to be commonly found in /usr/lib, for example, which wouldn't be in a default $PATH.

I'm open to a more fine-grained solution here. What should I look for in $PATH, msmtp or sendmail? Or maybe just look for $SENDMAIL and bypass the lookup altogether?

@goblin
goblin commented Jun 26, 2013

Yeah, historically it's a mess... I don't know what's the best way to fix it.

If it was me, I'd:

  1. check the $SENDMAIL env var
  2. check for msmtp in $PATH
  3. check for sendmail in $PATH
  4. check for msmtp in "known locations" (/usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin)
  5. check for sendmail in "known locations"

The reason I'd prefer to look for msmtp first is that if someone has msmtp installed, he's more likely to use it for outgoing mail. But then again there can easily be multi-user servers which have both installed and users might prefer to use one over another. Checking the env var would allow them to fairly easily set what they want to use, hence the top priority.

But this may be far from ideal...

@drewr
Owner
drewr commented Jun 28, 2013

Typically when someone is using msmtp, the machine is outbound-only, and thus only care about msmtp. In this case, sendmail is usually a link to the msmtp binary. At least, this is how I've operated for a while.

But I agree, this assumption doesn't work for everybody. Let's start with a $SENDMAIL option that will force postal to use it.

@drewr drewr added a commit that referenced this issue Jun 28, 2013
@drewr @drewr + Use $SENDMAIL from the environment, if provided.
Addresses issue #34.
bc17856
@drewr drewr added a commit that referenced this issue Jun 28, 2013
@drewr @drewr + Use $SENDMAIL from the environment, if provided.
Addresses issue #34.
72c6f46
@drewr
Owner
drewr commented Jun 28, 2013

I pushed 1.10.4 with this change. See how it works for you.

@rlbdv
rlbdv commented Sep 10, 2014

I think we might like to be able to just specify the sendmail path explicitly (disabling the auto-search), perhaps via a :sendmail option. Plausible? Otherwise we'd be stuck with an app wrapper that sets SENDMAIL (since you can't modify System/getenv) -- and then we couldn't change the path during a server's lifetime.

@the-kenny

Not being able to set this programmatically is a major annoyance right now. Please support either setting it via a dynamic binding, search in PATH or allow me to pass it as an optional argument to sendmail-send.

@drewr
Owner
drewr commented Oct 24, 2014

I agree we should add more dynamicity here. As a workaround could you
symlink to /usr/sbin/sendmail? Runtime changes would just involve changing
the link. Not ideal, will address it internally eventually.

@rlbdv
rlbdv commented Oct 27, 2014

If allowing a single string isn't sufficient, I suppose you could just have the hypothetical :sendmail option accept a function that returns the desired value (i.e. "/sendmail/you/want").

@drewr drewr added a commit that closed this issue Oct 28, 2014
@drewr Add sendmail parameter to sendmail-send
Fixes #34
7aac269
@drewr drewr closed this in 7aac269 Oct 28, 2014
@drewr drewr added a commit that referenced this issue Oct 28, 2014
@drewr Add sendmail parameter to sendmail-send
Fixes #34
361c2f8
@drewr
Owner
drewr commented Oct 28, 2014

Released 1.11.2. Thanks @the-kenny @rlbdv!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment