System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

mailx cannot send special characters in subject

SOLVED
Go to solution
LeMike
Occasional Visitor

mailx cannot send special characters in subject

Good morning,

I'm trying to send email by using mailx, but three scenarios arise:

Scenario 1
----------
I send an email including US-ASCII chars only ( no special chars ) in its body message, but including them ( special chars ) in the subject - In this case the body msg is well interpreted, but the subject appears scrambbled

Command:

echo "aeiou" | mailx -s "áéíóú" email_address

Results:

Content: (correct) - aeiou
Subject: (wrong) - =?iso88591?Q?=E1=E9=ED=F3=FA?=

Scenario 2
----------
I send an email including special chars only ( no special chars ) in its body message, but not in the subject - In this case everything is correct.

Command:

echo "áéíóú" | mailx -s "aeiou" email_address

Results:

Content: (correct) - áéíóú
Subject: (correct) - aeiou


Scenario 3
----------
I send an email including special chars in its body message, and subject - In this case, everything correct.

Command:

echo "áéíóú" | mailx -s "áéíóú" email_address

Results:

Content: (correct) - áéíóú
Subject: (correct) - áéíóú


Summary:
--------
When the body messages has any special character, the subject is well interpreted when including special chars on it, but it's not when the body message doesn't have it, and subject does.


Current settings:
-----------------
LANG=es_MX.iso88591
LC_CTYPE="es_MX.iso88591"
LC_COLLATE="es_MX.iso88591"
LC_MONETARY="es_MX.iso88591"
LC_NUMERIC="es_MX.iso88591"
LC_TIME="es_MX.iso88591"
LC_MESSAGES="es_MX.iso88591"
LC_ALL=

Terminal type allows to type special chars.
stty cs8 -istrip

.mailrc's contents:
set sendcharsets=iso88591
set charset=iso88591
set encoding=8bit


Could you help me to do the correct setup for sending email by using mailx, and have both (body message, and subject) well interpreted in all scenarios, please ?

Thanks in advance.
LeMike
4 REPLIES
Steven E. Protter
Exalted Contributor
Solution

Re: mailx cannot send special characters in subject

Shalom,

Lets eliminate mailx as an issue.

Try this script instead and see if you get the same results.

http://www.hpux.ws/?p=7

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
bright image
Frequent Advisor

Re: mailx cannot send special characters in subject

You could try using sendmail directly:

Put the email in a file in the format

To: user@domain
From: user@domain
Subject: some subject

message text

Then call sendmail with the following options:

/usr/lib/sendmail -vt < filename

The -t tells sendmail to read the file for its header information. You can add MIME headers to make it a html formatted email etc...

To make it a html formatted email just add these two headers:

MIME-Version: 1.0
Content-Type: text/html

and change your message body to be some valid html code.
LeMike
Occasional Visitor

Re: mailx cannot send special characters in subject

Thanks very much guys for your help!, Both solutions resolved my issue very well, and everything works fine now!.

Although It's also interesting why sending email with the special chars in its body msg causes the email to correctly interpret the charset to use.

Best Regards,

Sincerely,
LeMike
Dennis Handly
Acclaimed Contributor

Re: mailx cannot send special characters in subject

?Subject: (wrong) - =?iso88591?Q?=E1=E9=ED=F3=FA?=

That =?iso88591 is how a fancy mail client encodes your special chars. mailx isn't a fancy client so it doesn't format it.