How to add an X-header to unix mailx

emailsendmailunix

I am attempting to add the x-header X-APP-VOLT: Yes to the header of my email with a .tar attachment. I only have access to usr/sbin/sendmail and mailx. I do not have root access so I can't download other versions of mailx or mutt.

I can add the x-header to usr/sbin/sendmail using the below code, but I can't figure out how to add the .tar attachment.

/usr/sbin/sendmail -i -- toemail << END
To: toemail
Subject: Test
X-APP-VOLT: Yes
Hope this works!
END

I can attach a .tar file to mailx using the the below code, but I can't figure out how to add a x-header. My mailx also does not have the -a option.

cat file | uuencode filename | mailx -s "Test" toemail

Thank you

Best Answer

You can pipe output of multiple command into sendmail input.
If the code below does not work for you the name (command) shell you use.

(
# Command 1: "here document with headers and initial body lines
cat << END
To: toemail
Subject: Test
X-APP-VOLT: Yes
Hope this works!

Email Body line 1

END
# Command 2: uuencode file
cat file | uuencode filename
) | /usr/sbin/sendmail -i -- toemail