git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] send-email: allow sendmail binary to be used instead of SMTP

From
EWEric Wong <normalperson@yhbt.net>
Date
May 15, 2006, 09:27 UTC
Message-ID
<20060515092704.GB6855@localdomain>
In-Reply-To
<7vpsifx2b7.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano <junkio@cox.net> wrote:
Show 38 quoted lines
> Eric Wong <normalperson@yhbt.net> writes:
> 
> > This should make local mailing possible for machines without
> > a connection to an SMTP server.
> 
> Which is a good thing, but
> 
> > It'll default to using /usr/sbin/sendmail or /usr/lib/sendmail
> > if no SMTP server is specified (the default).  If it can't find
> > either of those paths, it'll fall back to connecting to an SMTP
> > server on localhost.
> 
> I do not know if it is OK to change the default to first prefer
> local MDA executable and then "localhost".  That is, ...
> 
> > @@ -179,8 +180,14 @@ if (!defined $initial_reply_to && $promp
> >  	$initial_reply_to =~ s/(^\s+|\s+$)//g;
> >  }
> >  
> > -if (!defined $smtp_server) {
> > -	$smtp_server = "localhost";
> > +if (!$smtp_server) {
> > +	foreach (qw( /usr/sbin/sendmail /usr/lib/sendmail )) {
> > +		if (-x $_) {
> > +			$smtp_server = $_;
> > +			last;
> > +		}
> > +	}
> > +	$smtp_server ||= 'localhost'; # could be 127.0.0.1, too... *shrug*
> >  }
> >  
> >  if ($compose) {
> 
> Without this hunk, people who did not specify --smtp-server=host
> could get away with having anything that listens to 25/tcp on
> the localhost that is not either of the above two paths; now
> they have to explicitly say --smtp-server=localhost to defeat
> what this hunk does.  I do not know if it is a big deal, though.

I believe this is what Martin wanted. I think it's a good idea since sendmail binaries tend to be more flexible, but I'm ok with it either way.

Of course, Greg and Ryan were the original authors of this, so I'd like their take on it, too.

> > +	if ($smtp_server =~ m#^/#) {
> 
> I like this if(){}else{} here, but have a feeling that the
> logging part should be placed outside it to be shared.

Cleaned that up a bit, patch coming. Also removed the Port: printout completely, as it's rather redundant (see below).

> While we are at it, we might want to enhance $smtp_server parsing
> to take host:port notation so that people can use message
> submission port 587/tcp (RFC 4409) instead.

This already works, IO::Socket::INET (behind Net::SMTP) takes care of it :)

-- 
Eric Wong
Previous: Junio C HamanoNext: Eric Wong
Message 7 of 17 in “send-email: allow sendmail binary to be used instead of SMTP”
  1. send-email: allow sendmail binary to be used instead of SMTPEric Wong, May 15, 2006
  2. Eric WongMay 15, 2006
  3. send-email: quiet some warningsEric Wong, May 15, 2006
  4. Junio C HamanoMay 15, 2006
  5. send-email: quiet some warnings, reject invalid addressesEric Wong, May 15, 2006
  6. Junio C HamanoMay 15, 2006
  7. Eric WongMay 15, 2006
  8. send-email: allow sendmail binary to be used instead of SMTPEric Wong, May 15, 2006
  9. Junio C HamanoMay 15, 2006
  10. Eric WongMay 15, 2006
  11. Martin LanghoffMay 15, 2006
  12. Junio C HamanoMay 15, 2006
  13. Eric WongMay 15, 2006
  14. Ryan AndersonMay 15, 2006
  15. Junio C HamanoMay 15, 2006
  16. Ryan AndersonMay 15, 2006
  17. Martin LanghoffMay 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.