Active
Project:
Simplenews
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
6 Sep 2012 at 11:15 UTC
Updated:
9 Sep 2016 at 11:39 UTC
Jump to comment: Most recent
The unsubscribe link in my Simplenews footers is correct, other than having an http://default instead of the correct URL at the start. Strangely, this isn't like this in the test messages from Simplenews, which also do not seem to be using any of the theme templates. I am using the token [simplenews-subscriber:unsubscribe-url] as per the Simplenews documentation.
This seems to be a problem with the URL being correctly replaced in the token. Can you advise on the best way to fix this, in either my setup, in Domain Access, or in Simplenews?
Comments
Comment #1
agentrickardHow are these files being generated? Through a normal Drupal page request or via the command line (e.g. during a cron run)?
This typically happens when using drush or other CLI tools that don't pass a $_SERVER['HTTP_HOST'] option, which you can correct by passing a --url value in the command.
Comment #2
babbage commentedFabulous. Thanks agentrickard, you've hit the nail on the head and it wasn't an angle I'd even considered. The newsletters are sent out on cron, and I was running
drush cronto make it happen immediately. Usingdrush cron --uri=example.comfixes the problem.Will check this, but seems highly likely this isn't even associated with Domain Access module after all, and would happen on any site where the site is installed in sites/all/default and where newsletters are sent after cron is run from drush without a uri parameter specified. I hadn't seen this on my other site where I was using Simplenews, so wondered if it was associated with using Domain Access on this site, but it seems more likely I just was running the cron via the web browser when testing the setup on the other site.
Moving to Simplenews issue queue. I'll have a look at this further to confirm the limits around the circumstances in which this occurs.
Comment #3
miro_dietikerYes this is a known issue.
Basically it possibly lacks documentation.
In my opinion, this is a bug of drush or even drupal core.
"default" or "localhost" is just NO reasonable default. Instead the system should apply its known base URL.
Note that with multisites this is not really clear... So if you check the drush documentation, it states:
"URI of the drupal site to use (only needed in multisite environments)"
This means, drush can not provide any reasonable default for these cases...
I'm happy if you can help us improving the documentation.
Also i suggested to the drush team once to completely ban drush executions without uri parameter in case of multisites.
Also we considered stopping cron excution if w detect cases such as "default" or "localhost".
But basically no one feels responsible for such a messy result.
What i can say for sure is: Simplenews is the wrong place to fix it. We just could detect the failure and avoid sending out spam.
Comment #4
agentrickardWell, specific to this issue, DA does require a URL parameter, because you may wish to send newsletters from specific domains.
I think this is a documentation issue (possibly for Drush), but its covered in the DA docs (and cron) as well.
Any cron implementation is supposed to pass a valid URL request. See http://drupal.org/cron
Comment #5
agentrickard@babbage
And, specific to DA, if you need to send newsletters from various domains, you may need an implementation of hook_domain_cron() as well. See the DA API file.
Comment #6
babbage commented[headslap] Encountered this issue of my Simplenews footers again having a broken unsubscribe link that was http://default/... Thought I'd mis-edited my footer template. Google brought me back to find myself walking in my own footprints. Must hard-code a solution to this somehow. :)
Edit to add: This is not a problem associated with Domain Access in any way. It occurs if Drush is used to activate cron on any site where the site is installed in the sites/default folder and where a --uri parameter is not passed. See https://github.com/drush-ops/drush/issues/87
Comment #7
babbage commentedIt would be fabulous if Simplenews refused to send out hundreds of newsletters with an invalid unsubscribe link when I ran
drush cronwithout thinking. :)Comment #8
miro_dietikerPatches welcome.
Comment #9
jaylotta commentedIf you set the base url in settings.php then cron will use that value.
It's not the right solution, but it is a workaround.
Comment #10
miro_dietikerI didn't test it recently, but setting a base url in settings.php did NOT affect any drush (cron) call.
See also related task
#2396121: Stop sending via cron without meaningful hostname
Comment #11
ariban99 commentedany update on this? its still happening on all my different drupal installs!
can anyone help with this?
what if someone does NOT have drush. they simple go to contents > newsletter and push send newsletter (in simplenews, its selected to use cron to send newsletter 200 at a time and cron runs every 3 hours)
any help will be greatly appreciated.
Comment #12
rcodinaI also reproduced the error.
Comment #13
miro_dietiker@ariban99 If you click it in the UI through the browser, the link will point to the current URL domain or the base URL configured.
This really only is a drush issue.
For Drupal 8, we solved this:
Backports welcome.