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.
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?
Yeah, historically it's a mess... I don't know what's the best way to fix it.
If it was me, I'd:
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...
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.
Use $SENDMAIL from the environment, if provided.
Addresses issue #34.
I pushed 1.10.4 with this change. See how it works for you.
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.
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.
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.
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").
Add sendmail parameter to sendmail-send
Released 1.11.2. Thanks @the-kenny @rlbdv!