0

I've got a weird problem with Swiftmailer 5.x:

  $mailUrl = htmlspecialchars("$serverDiff/test/?action=passwordreset&token=$user_token");
  $mailtext = "Für Ihren Account wurde das Zurücksetzen des Passwortes veranlasst. Bitte gehen Sie über folgenden Link, um dies einzugeben: $mailUrl";
  $mailtext = $textclass->text($mailtext);

This always returns & token= which, of course, is wrong. No matter how often I try to utf8_decode, encode, htmlspecialchars it or just try using the xhtml or unicode for the ampersand it still switches to &

Does anybody have an idea how to fix this? I already asked a bunch of colleagues and friends and no one knows ... Thank you very much!

Matt
  • 5,315
  • 1
  • 30
  • 57
Lightningsoul
  • 552
  • 5
  • 16
  • The question isn't clear. Is `$mailtext` set to `& token=` after those three lines? If so, what is textclass and the text() method doing? – Matt Mar 29 '17 at 17:27
  • Nope, it was being changed by a later framework function called setBody. See answer beneath, please. But thank you for answering / commenting. – Lightningsoul Mar 29 '17 at 18:50

1 Answers1

0

I finally soluted this with the help of another post that lead me right to the answer: https://stackoverflow.com/a/31426274/2181606

Just went into the framework (/swiftmailer-5.x/lib/classes/Swift/Mime/MimePart.php) in line 64 (setBody function) and inserted this (see line 2, first is just for positioning reference):

    $body = $this->_convertString($body);
    $body = str_replace('&', '&', $body);

Thank you, me. :D

Community
  • 1
  • 1
Lightningsoul
  • 552
  • 5
  • 16