On 2020-08-06 Otto Kekäläinen wrote:
> Is it possible to send email using the Postfix provided
> /usr/sbin/sendmail command on a system where Postfix is installed,
> but not running permanently as a service?

You could wrap the command in a script that starts and stops the Postfix
service when invoked.

    #!/bin/bash
    sudo service postfix start
    sendmail ...
    sudo service postfix stop

However, I wouldn't recommend doing that since you'd have to manage
concurrency, handle errors and other fun things.

Postfix isn't that heavy on system resources. Just configure it as a
null client [0] that sends to your upstream Postfix and leave it running
in the background.

Alternatively use something like mailx [1] to send directly through the
upstream server:

    echo "message" | mailx -S smtp=smtp://mail.example.com ...

[0]: http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
[1]: 
https://www.systutorials.com/sending-email-using-mailx-in-linux-through-internal-smtp/

Regards
Ansgar Wiechers
-- 
"Abstractions save us time working, but they don't save us time learning."
--Joel Spolsky

Reply via email to