Hi there.
I'm using the Simplenews and the HTMLMail modules to generate HTML newsletters and i couldn't get the replacement patterns to work.
I tried with the Mime module too but with no luck.

The only way i receive the right links on my email is when sending plain text newsletters otherwise it simply won't replace the patterns.
This is what happened to me with the several combinations of the modules and with the [simplenews-subscriber:unsubscribe-url] pattern (i only needed this one):
simplenews + htmlmail : replace with a empty string ""
simplenews + htmlmail + pathologic: the entire pattern maintains.
simplenews + mimemail : the entire pattern maintains.
simplenews plain text newsletter: the correct links are passed

I manage to solve my problem generating the hash myself on the message templates with the function simplenews_generate_hash:
simplenews_generate_hash( $params['context']['account']->mail, $params['context']['account']->snid, '2')

Comments

miro_dietiker’s picture

einzelkind’s picture

+1 same issue here

berdir’s picture

Will need to investigate, from looking at the code this shouldn't happen.

Anyone else experiencing this?

berdir’s picture

Status: Active » Fixed

I've just written some tests which verify that html mails are being sent with the tokens replaced. There also haven't been any reports lately about this. Marking as fixed.

If you still experience this, please re-open and describe exact steps on how to reproduce, including what kind of tokens you are using.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

inteja’s picture

Priority: Critical » Major
Status: Closed (fixed) » Active

In my case (using Simplenews 6.x) it was/is Pathologic that was preventing token replacement in emails. See this Pathologic issue http://drupal.org/node/1421868

berdir’s picture

Status: Active » Closed (fixed)

Then why would you re-open this issue if it the problem was another module? :)

inteja’s picture

I didn't (and still don't) know where the fault lies i.e. with Simplenews or Pathologic. Sorry I should have worded my comment better as I implied it was a pathologic issue. In reality I don't know.

All I do know is that Pathologic seems to interact flawlessly with other modules, but not Simplenews and I read somewhere that (if I recall correctly) Simplenews, by design, does token replacement late, which may have something to do with Pathologic not being able to do token replacement with it. But that's just a guess.

pavel.karoukin’s picture

I was able to get around it by using hook_pathologic_alter() from latest dev version of Pathologic 7.x. I just added this into one of my custom modules:

function MODULENAME_pathologic_alter(&$url_params, $parts, $settings) {
  if (preg_match('/^\[.+\]$/', $url_params['path'])) {
    $url_params['options']['use_original'] = TRUE;
  }
}

This will skip any URL which matches [.+] pattern.

duaelfr’s picture

This only works for URLs containing only a token or starting and ending with a token.

<a href="[user:url]">My link</a> works
<a href="/node/[node:nid]/edit">My link</a> does not work

I am looking for a way to make this work natively in Pathologic.

duaelfr’s picture

Status: Closed (fixed) » Active

I found that it is the url function call within pathologic which encodes tokens, but no hook is available to avoid this behavior.

Maybe we should add a condition if token is enabled which would decode tokens only but it seems a bit hacky.