Search

I’ve been setting up e-mail templates for one of my sites tonight, and I’ve hit a weird bug:

I like my article titles to use proper typographic characters, so I use my Typogrify extension applied to Rowan’s Textboxes for my title fields. Problem is, they come through like this whenever I try to send them via e-mail:

tonyarnold.com: A new comment has been postedG9uICdHZXQgU2F0aXNmYWN0aW9uIGZvciB1c2VyIHN1cHBvcnQgLSBkb2VzIGl0wqB3b3JrPyc=

whereas it should be:

tonyarnold.com: A new comment has been posted on ‘Get Satisfaction for user support - does it work?’

Any ideas short of switching back to an unformatted text field?

I could be wrong, but that garbled text looks alot like a multipart boundary string. You should be able to look in the email’s content-type header; if it’s there as well, then that is the source of your problem.

what ashooner said. It looks like the post title isn’t added (possibly because it’s a different field?) and the boundry is getting pushed up into the title because there is no proper “\r\n” before it / after the title.

You’re both right - I hadn’t noticed how familiar that string looked. Thanks for the tip.

It looks like it’s happening to a whole bunch of fields in the header:

Subject:
 =?UTF-8?B?dG9ueWFybm9sZC5jb206IEEgbmV3IGNvbW1lbnQgaGFzIGJlZW4gcG9zdGVkI?=
 =?UTF-8?B?G9uICdHZXQgU2F0aXNmYWN0aW9uIGZvciB1c2VyIHN1cHBvcnQgLSBkb2VzIG?=
 =?UTF-8?B?l0wqB3b3JrPyc=?=
From: =?UTF-8?B?TXIgTWFnb28=?= <magoo@happyland.com>
Reply-to: =?UTF-8?B?TXIgTWFnb28=?= <magoo@happyland.com>

I’m not sure why this is defaulting to multipart - it’s just a simple comment form.

I fixed this by slightly modifying symphony/lib/toolkit/class.general.php - specifically the encodeHeader method:

http://gist.github.com/151888

/***

Method: encodeHeader
Description: Encodes header
Source:      http://bitprison.net/php_mail_utf-8_subject_and_message
More info:   http://www.ietf.org/rfc/rfc2047.txt

***/
public static function encodeHeader($input, $charset='ISO-8859-1'){
    //  $separator = "?=".self::CRLF."=?{$charset}?B?";
    //  return "=?{$charset}?B?".wordwrap(base64_encode($input), 75-strlen($separator), $separator, true).'?=';
    return "=?{$charset}?B?" . base64_encode($input) . '?=';
}

Sorry to resurrect such an old thread but I’m having the same problem with my Send Email titles but I’d rather not modify the core to fix it. I’m doing quite a lot of customisation in the event PHP, in particular I am setting the e-mail subject like this:

$_POST['send-email']['subject'] = $_POST['fields']['name'] . ' commented on ' . $_POST['fields']['content-title'];

I am also setting the e-mail recipient and body (where the same form values used in the subject appear correctly) and the Akismet fields. There is logic for author comments too. Everything works as expected apart from the e-mail subject which, 50% of the time, appears like this in Thunderbird:

=?UTF-8?B?UGFycmlzaCBTbWl0aCBjb21tZW50ZWQgb24gSW1pdGF0aW9ucyBGcm9tIEhvb?=  =?UTF-8?B?WU=?=

In GMail most of the subject is intact but the last few letters are corrupted. I’m not sure where to start on this. Any suggestions?

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details