I am trying to sending an email in html format. but its not working.
echo "<html><b>Hello</b></html>" | mailx -a "Content-type: text/html;" -s "Testing" me@xmple.com
Returns :
mail: illegal option -- a
mail: Usage: [-ehpPqr] [-f file] [-x debuglevel]
or [-tw] [-m message_type] [-T file] [-x debuglevel] persons
or [-x debuglevel]
but the same command is working with out -a option which is not a html.
echo "<html><b>Hello</b></html>" | mailx -s "Testing" me@xmple.com
The -a
is a file attachment in the GNU version of mailx
. Most other versions of mailx
don't support that option since they're mainly concerned with text-based mail. There is not much you can do to get this to work. Here are some options:
If this is merely text you want to email, simply redirect it to the mail command:
$ mailx -s "Here's the info" bob ted alice < file.txt
In the old days, we would uuencode the file. This would convert any file to a 64 character subset of ASCII characters that all computers understood. (Many computers in the old days only had 6-byte characters, thus 64 characters). You would uuencode
the file, then attach it to the email. The recipient would save the attachment and uudecode
the file.
$ uuencode -o file.uuencode file.jpg file.jpg
$ mailx -s "Here's the jpg (uuencoded) bob ted alice < file.uuencode
Or, you can use a scripting language like PHP, Perl, or Python that can do MIME encoded mail.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.