0
PARAMS='--port=25 --tls=on --tls-starttls=on'
echo "Subject: test" | sendmail $PARAMS

I want to reuse a parameters, and use them in sendmail.

Result: sendmail: fatal: usage: sendmail [options]

What am I doing wrong here?

The linked question suggests refactoring into a function, which works:

sendme() {
   echo "test" | sendmail --port=25 --tls=on --tls-starttls=on
}

sendme

  • Can you explain how the suggested duplicate fails to answer your question? The accepted answer there is very good and gives you both an explanation and multiple solutions. If you still need help, please [edit] your question and clarify what else you need. – terdon May 12 '22 at 14:25
  • Sorry didn't mean to hammer this one closed but I do believe the linked question has multiple solutions to this. Mainly an array might fit your needs here. You don't necessarily have to store the whole command, you could also just store the options in an array. – jesse_b May 12 '22 at 14:55

0 Answers0