mailx question specifying content-type

hello -

i remember John Q told me to quit using sendmail and use mailx instead, i think perhaps he mentioned security issues?

lately Gmail is occasionally coming through as just a "noname" attachment with google. i have researched two workarounds (i am merely emailing the server date as an example):

SUBJECT='test test TEST' ; SUBJECT=${SUBJECT}$(echo -e "\nContent-type: text/html") ; echo `date` | mailx -s "$SUBJECT" mark@marky.com ;

echo `date` | mailx -s "test test TEST $(echo -e "\nContent-type: text/html")" mark@marky.com ;


i am not satisfied with either solution. many forums talk about using the -a switch, but in Centos7 the -a switch is only used for actual attachments.

any suggestions?
 

Quags

Administrator
Staff member
-a switch might be for another version like bsd mailx

You could auth the email and get a content type

echo "${ERROR_NOTICE}" | ${MAILX_PATH} -s "${ERROR_SUBJECT} ${HOSTNAME}" -S smtp=${smtpserver} -S smtp-auth=login -S smtp-auth-user=${smtplogin} -S smtp-auth-password=${smtppassword} -S from="${smtpfrom}
 
hi John, i am not sure that works. when i tried that, it included the Content-type: text/html text as part of the email body. its as if mailx is including the "\n" linefeed for us, so anything you pipe into it will just become part of the email body.

i am very surprised that mailx does not have something a little more sophisticated to deal with this issue. -a is only for attachments in the centos-7 mailx version from what can tell. i should think it would be very easy for the mailx maintainers to include a new switch command for stuff like this (or perhaps are assuming the same about me that i will do it? :) )

appending a line to the subject seems like a big hack-job to me.

maybe i might take this up on stack-overflow, but i did quite a bit of research and did not find a better answer.
 
Top