user127192 user127192 - 1 year ago 83
Bash Question

Send e-mail with custom From: and Cc:

I am trying to automate my email by using this command on unix VI:

echo 'Message body goes here' | mail -s 'subject line goes here'

However, I would like to add a "CC" and use a different email address showing when I send the email to the recipient.

Answer Source

mailx is usually link with mail.

Try passing the options to sendmail by putting double-dash at the end and then specifying -f (from) or -r (return):

mailx ....    -- -r

mailx ....    -- -f

You could also try "-a" option as mentioned here

mailx -a ''  ...

If you want to try the sendmail:

sendmail -t <<EOF
Subject: Hi
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download