FAQ | Frequently Asked Questions

brought to you by your friendly
UC Davis Geology Department Computing Support Team

Q: How can I filter out e-mail messages that are completely in a foreign language?
A: If the target message all contain a Content-Type header listing a foreign character set then this is easy.

For example, suppose you are receiving a lot of messages, which might be junk, that are all in Japanese characters. Here's an example in Apple Mail:


Next we need to view the message headers to see if there is some criteria on which we can filter the message. To view the message headers in Mail, select ViewMessageLong Headers. The mail message window should now look something like this:


Scroll down through the headers looking for one named Content-Type.


Here we find the Content-Type header with a value of “text/plain; charset=Shift_JIS”. E-mail messages that we exchange in the US typically have a Content-Type of “text/plain; charset=UTF-8” or “multipart/alternative;”. So this appears to be a criteria on which we could base a filter.

Looking up Shift_JIS in Wikipedia we learn that "Shift JIS (also SJIS, MIME name Shift_JIS) is a character encoding for the Japanese language, originally developed by a Japanese company called ASCII Corporation in conjunction with Microsoft and standardized as JIS X 0208." You can find the names of other character set encodings here.

To create such a filter, first select the message in your Mail Inbox. Then select MailPreferences… click the Rules tab and then click the Add Rule button.


In the Description field enter something appropriate, such as Shift_JIS.


Next we want to add a condition based on the Content-Type header, but that header is not one of the defaults so we need to add it to our defaults. Click and hold on the Any Recipient button and select Edit Header List… from the pop-up.


In the Message Header window click the plus sign (+) in the lower left corner, enter Content-Type and click OK.


Now return to the Rules window and select the Content-Type header from the Conditions pop-up.


Once Content-Type is selected, the Contains field should auto-fill with the value from the selected message: “text/plain; charset=Shift_JIS”. Scroll to the right end of the field to verify this.


If it is not set, you can enter Shift_JIS in the Contains field manually.

Finally, set an action for the message, such as Move Message to mailbox: Junk, and click OK.

After you click OK you should see a window asking Do you want to apply your rules to messages in selected mailboxes?


If you click Apply then Mail will immediately apply the new rule to your Inbox and the target messages should move to the Junk mailbox from the Inbox.

If you click Don’t Apply then Mail will not apply the new rule to existing messages in your Inbox, but will apply it to any new messages.