Recently we have moved to Kubernetes cluster from on-premise infra. I was able to send HTML format emails (inline) in sendmail unix command but when I tried to do the same in mailx command it is not sending the HTML format rather printing the HTML tags in the mail body .
I had searched the other topics mentioning the same issue and also tried to use the proposed code but it is giving the same issue. The solution which worked for others is not working for me.
The issue is that mailx is not properly interpreting the Content-Type: text/html header when you pass it in the subject using -s. That is not the correct way to send an HTML email.
To send HTML emails using mailx (specifically the Heirloom or BSD version), you should use the -a option to specify the content type.
Thanks — you’re using the BSD mailx 12.5 version, which does not support -a "Content-Type: text/html" like Heirloom mailx does. In BSD mailx, the -a flag is for attachments only, not headers.
Yes, but from my reading, if you manually create the subject (as above) the -s option is not required - but folks are welcome to use -s if they prefer.
This is easy enough to confirm or not, but I don't have access to this version of mailx, sorry.
Alternatively, you could create a bin shared volume between your host and container and run a staticly compiled version of sendmail or mutt or a different version of mailx from the host in your container.
That way you can keep the base image clean - and use a shared vol.
Same architecture: e.g., x86_64 host ↔ x86_64 container.
Statically linked binaries: These don’t rely on host/container shared libraries (glibc, libc, etc.), so they’re portable across distros.
Obviously mailx adds a newline before the body text starts, so the header ends there.
Linux mailx has option -t that promises to take the header from the top of the message, and ignoring all header options.