Forum Discussion
SMTP has two Froms, one is in the SMTP commands (FROM xxx) and the other is in the message headers (From: xxx). I think there is some way to get sendmail to read the headers to infer the "FROM" it should use, but you can just use the -f switch to set it when you call it from a script. This is more of a unix question rather than APM: The delivery agent used by APM is completely separate from sendmail.
Your command would then look like:
echo "message data here" | sendmail -f 'ops-noreply@company.com' 'recipient@company.com
Google "sendmail from address" for more in depth discussion on this topic and information about how different user agents need this to be formatted to display a "friendly name" part of the address. Also be sure to sanitize username input if it's from an external source, especially those usernames with apostrophes, parens, or shell script injection attacks.
- David_GillNov 06, 2015CirrusIt does not work for me. Even using the simplest format as you have shown above still comes out as root [root@hostname.company.com]. I tried with single quotes, double quotes, no quotes, space after the -f, no space after the -f. Does that one line sendmail command work for you?