Sending mail to SMTP from command line

Brian Candler B.Candler at pobox.com
Tue Jan 24 11:05:44 PST 2006


On Mon, Jan 23, 2006 at 08:29:41PM -0500, George Georgalis wrote:
> On Sun, Jan 22, 2006 at 01:07:49PM -0600, Kenny @ Gmail wrote:
> >Google is your friend.
> >http://www.yuki-onna.co.uk/email/smtp.html
> 
> I don't think that's what the OP had in mind... atthis moment I'm
> typing with a broken terminal... at least I can use vim...
> 
> problem is no /usr/lib/sendmail replacement that doesn't require a
> daemon to watch the queue and connect to remote hosts.
> 
> in this age of regulated sites that would be really handy too. eg
> at a financial site, it would be really useful to not run a smtp
> daemon (even only on 127.0.0.1) to avoid the audit; but still have
> a sendmail replacement which forks and tries to deliver the mail
> for seven days eg one process for each message, or something more
> advanced, one process for a queue in a tempdir which disappears
> when each message is delivered and the process ends. (my idea,
> public domain)

You can install a sendmail replacement which has no queue - it just opens a
port 25 connection to a designated smarthost(s) and dumps the mail there.
The process runs in the foreground and if it can't forward to the smarthost
then it exits with a non-zero exit code. Examples of this are mail/ssmtp in
ports, and exim in its "mua_wrapper" mode.
http://www.exim.org/exim-html-4.60/doc/html/spec.html/ch47.html

(Note that exim still does write the mail to its spool directory
temporarily, and therefore needs to be run setuid or setgid to the spool
owner, but it doesn't need root)

Not all user programs properly handle the return code from a foreground
sendmail process, however.

If you actually want the mail to be stored in local queue with background
retries if necessary, just run a regular MTA, but turn off its smtp daemon.
In many cases, just change '-bd -q30m' to '-q30m'

Regards,

Brian.


More information about the freebsd-isp mailing list