Skip Navigation

[Resolved] Email notifications body encoding issue

This support ticket is created 4 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 35 replies, has 2 voices.

Last updated by Christian Cox 4 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1494625
weird-cyr.png

Hi guys,

I am having this weird email notification encoding issue.
My notifications are in cyrillic and they seem to be encoded in a way that my Mail.app (OS X email client) doesn't seem to like a lot.
Note that it is only in the excerpt part that is displayed just under the name and subject line on the left column. The right column where the full email body is shown seems to look as expected. Screenshot attached.

Any ideas?

#1494797

Hi, how is the strangely encoded part placed in the notification body? Is this a combination of shortcodes, or plain text, etc? Please copy + paste the notification body code here for me to review and I'll provide some feedback. Thanks!

#1494911

Hi Christian,

It is a mix of plain text + shortcodes, but even the plain text goes mumbo-jumbo.

Благодарим Ви <strong>[wpv-post-author]</strong>!
Вашата инициатива <strong>[wpv-post-title]</strong> бе успешно добавена в палтформата.
Моля изчакайте одобрение от администратор.

Това е автоматично генерирано известие от платформата Принос.бг
#1494913

As a test, can you try setting the Content Type header to charset UTF-8 using the cred_mail_header API?

function set_cred_notifications_utf8( $headers, $formid, $postid, $notification_name, $notification_number ) {
    if ($formid==123 && $notification_number==0) {
        $myheaders = array( 'Content-Type: text/HTML; charset=UTF-8' );
        return array_merge($headers, $myheaders);
    }
    return $headers;
}
add_filter('cred_mail_header', 'set_cred_notifications_utf8', 10, 5);

Change 123 to match the Form ID, and change 0 if the notification is not the first in the list of notifications applied to this Form. It should be a zero-based index.

https://toolset.com/documentation/programmer-reference/cred-api/#cred_mail_header

#1494919
Screenshot 2020-02-05 at 20.52.36.png

Nope, got a parse error with this one:

Parse error: syntax error, unexpected 'return' (T_RETURN) in /.../wp-content/themes/platform/functions.php on line 124

comes from this line

return array_merge($headers, $myheaders);

but I believe it has to do this this code here

$myheaders = array( 'Content-Type: text/HTML; charset=UTF-8' );

Also my code editor doesn't like those #'s

#1494981

Looks like your copy + paste converted some characters incorrectly. Check my post code, then compare that with your code. You can see that single apostrophes were converted incorrectly somehow during your copy + paste.

#1494987

I just realised this too. Sorry I was too quick..

#1494999

OKay tried it, but it doesn't seem to help.

Both the admin notification which is number 2(1) in the list, and the client notification which is number 1(0) in the list do have the same issue.

Also I have a third notification, that I set up to be fired when the post gets approved by the admin ( I set up "when the post status changes to "public") that never fires even after I change the status from "pending" to "public" ? - But I guess this one is for another ticket.. Just wanted to mention this issue too.

#1495097

Okay just fwded it. It will come from a @green.bg email.

#1495101
Screen Shot 2020-02-05 at 3.06.45 PM.png
Screen Shot 2020-02-05 at 3.04.13 PM.png

Strange, the email came through okay for me without any unusual formatting. So I copy + pasted the contents into another email and sent it again, but the formatting looks okay in the subject area for this one as well. I tested in Gmail and Mac OS X mail clients. Can you test with another email client? Is the notification formatted incorrectly in every email client, or just one specific client?

#1495323
75D8A854-1E25-4CAA-965B-7D1BAB9FBDDA.jpeg

The issue is with Apple Mail client only. Both on OS X and iPad OS

Here is a screenshot from my iPad.

I don’t use other email clients than Apple’s Mail.app

Notice the other email marked with green that looks as expected.
This issue affects only the left column with the excerpts. All looks good in the body itself.

D.

#1497193
mac-email-client.png
ios-notification.png
ios-email-client.png

After a few hours testing, I'm still having trouble replicating this issue. I set up a test site, a custom post type, and a Form that publishes that post type. I set up an automatic email notification and copy + pasted the code exactly as you provided it to me. I published a post with some Bulgarian text using the Form and checked my email in both the Mac OS X mail client and my own iPhone. I don't currently have access to an iPad to test with, and the iOS simulator does not include the mail client so I'm not able to test in that specific configuration. I'm attaching screenshots here showing what I see. No weird formatting in any of these. I didn't add the custom code snippet to set email headers...so this is the default content type and character set. We can try these two test next:

1. I will configure the email notification on my test site to send to the email address you have been testing with. Is it the same as your Toolset.com profile email address at efi.im? I will assume it is for now, and send you a notification in a few moments. Please let me know the results of that test, or I can provide private reply fields so you can share a different email address.

2. You will temporarily configure the email notification on your site to go directly to the OTGS email address I sent you earlier. This will eliminate the forwarding step in the process so I should receive exactly what you would normally receive. My day is closing here but I will return Sunday to continue investigating. Feel free to submit the Form to trigger the email notification at any time between now and then. Do not use the "Send a test email" feature, please actually submit the Form.

Some thoughts on the possible outcomes of these two test emails:

- If the email I receive is formatted correctly, then my guess is there is a configuration difference in our local environments. Something like a language setting, a keyboard preference, font setting in the mail client, a mail client plugin/extension, or something along those lines.

- If the email I receive shows the strange formatting, I'll have a bit more to investigate.

- If the email you receive is formatted correctly, then my guess is there is a server-side configuration difference. Something like the server local language, server character set, the database collation, or something along those lines.

- If the email you receive is formatted incorrectly, then my guess is there is a configuration difference between our local environments because the same notification produced different results in my local.

#1500015

Okay I did configure the admin notification to go to your email address and submitted a new post.
I will keep it this way for today so you can submit yourself too.

Also btw I did not get a notification from your test site to my @efi email. Double-checked that.

#1500747
Screen Shot 2020-02-09 at 2.09.32 PM.png

Okay thanks. I received the email from your server and saw the garbled response you mentioned in my Mac OS email, so I can confirm the problem. However, the response from my server is not garbled. Here's a screenshot of the difference. I sent a test message to you again a few minutes ago, did you receive?

#1500907

Yes I got it and it looks good.

So It’s the server configuration.
I guess I’ll have to contact my hosting support regarding this issue.

Lets keep this thread publicly available for them to look at, then I’ll post the solution in case someone else faces a similar issue.