So this is kind of a weird issue. I've got Simplenews setup, with Mimemail on a clients site and we're trying to get her email campaign launched. Unfortunately, with our first mass mail out we've run into a problem. When we create the newsletter, and send a test email everything looks great. However, when we go ahead and send the newsletter the urls in the email are messed up. Only the emails generated by the system are messed up, not the once I created in the newsletter template. Here is what I see when I check the raw source of the message.

Good URLs - Test email sent out.

 <div class="views-field-field-eventimage-fid" style="float:left;	margin-top:0;	margin-left:0;	margin-right:10px;	margin-bottom:25px;">
                 <span class="field-content"><img src="https://artisansontaylor.com/sites/default/files/imagecache/events_exhibits/Picture5.png?utm_source=newsletter&amp;utm_medium=email&amp;utm_campaign=Montly%20Exhibit%20-%20Artisans%20On%20Taylor" alt="Kim Kopp and Jim Kraft" title="Quiet Line - In Clay &amp; Paper" class="imagecache imagecache-events_exhibits imagecache-default  
imagecache-events_exhibits_default" width="300" height="385"></span>
   </div>

   <span class="views-field-title">
                 <span class="field-content"><a href="https://artisansontaylor.com/news-exhibits/quiet-line-clay-paper" style="color:#b1b637;	text-decoration:none;"><div class="upcomingeventtitle" style="font-size:1.5em;	display:inline-block;">Quiet Line - In Clay &amp; On  
Paper</div></a></span>
   </span>
   
Bad URLs - Production/Mass emails via cron

<div class="views-field-field-eventimage-fid" style="float:left;	margin-top:0;	margin-left:0;	margin-right:10px;	margin-bottom:25px;">
                 <span class="field-content"><img src="http:///sites/default/files/imagecache/events_exhibits/Picture5.png" alt="Kim Kopp and Jim Kraft" title="Quiet Line - In Clay &amp; Paper" class="imagecache imagecache-events_exhibits imagecache-default  
imagecache-events_exhibits_default" width="300" height="385"></span>
   </div>

   <span class="views-field-title">
                 <span class="field-content"><a href="http:///news-exhibits/quiet-line-clay-paper" style="color:#b1b637;	text-decoration:none;"><div class="upcomingeventtitle" style="font-size:1.5em;	display:inline-block;">Quiet Line - In Clay &amp; On  
Paper</div></a></span>
   </span>

I'm not really even sure where to begin in tracking down this issue. Any help would be great.
Thanks

Comments

sutharsan’s picture

You may need to set the base URL. See the readme.txt

roball’s picture

Title: Bad URLs when buld emailing » Bad URLs when bulk emailing
Priority: Critical » Normal

So is this issue solved then?

hansrossel’s picture

I had the same problem. Test emails have OK absolute links, real emails have http://localhost/.... links for images and the unsubscribe link.

It's quite annoying that this only happens for the real emails that are sent to clients and not for the test email which is ok, so it's not possible to see in advance there is a problem with relative/absolute paths. You only notice it after having sent out thousands of emails with broken urls.

I changed the settings.php now. The biggest problem I find here is that the real final email that is sent is different than the test mail.

hansrossel’s picture

Version: 6.x-1.1 » 6.x-1.3

I think I found my problem. We had moved the site to another server and crontab was set to call http://localhost/cron.php instead of http://www.example.com/cron.php. I suppose this is also the reason why http://drupal.org/node/439016#comment-2476518 mentions it only happens when you send on cron and not when you send immediately. So best to check your crontab settings.

miro_dietiker’s picture

Drupal itself has a hostname detection based on the request URL.
So if there's something wrong with it, it's a drupal issue - not simplenews.
As previously told: adding a base_url will solve all related issues.

Instead of implementing special workarounds i suggest the following:

We might add a check for base_url definition and output a warning on the drupal status page about this issue.
See hook_requirements:
http://api.drupal.org/api/function/hook_requirements

Someone to implement this and provide a patch?
I think we should add this to 6.x-1.x and all future releases.

jlockhart’s picture

Version: 6.x-1.3 » 6.x-1.x-dev
Status: Active » Needs work

Thanks for your response. I don't have the base_url set, so I'll try that with future projects. Unfortunately the client has decided to keep her MailChimp account so won't need this functionality. I would like to offer this as a built in solution for my sites, so I'll try your solution. Not entirely sure how I'm going to test it though :D Any suggestions on sending a mass email like that?

miro_dietiker’s picture

simon georges’s picture

Miro, it seems Drupal always define a $base_url (see conf_init()), so we can not really check if $base_url is defined. I'm willing to provide a patch for hook_requirements, but what should I check ? That $base_url is different than localhost ?

miro_dietiker’s picture

You cannot check the resulting url in hook_requirements.
You'll always visit hook_requirements via browser while a send process might still be triggered via localhost wget (resulting in different variable).

It comes up in my mind to even preg_match for the term ^\$base_url. But this will be wrong in some cases.

What we can do is checking for the known terms (127.x.x.x and local*) in the hook_cron. We then either need to set a variable to show later in hook_requirements...
Or output a watchdog message... Or send a warning to the site admin... ;-)
At least we should omit sending if such a case was detected.

(Note that in a multilingual setup, URLs even could switch depending the current language... So it wouldn't be possible to e.g. define a separate variable containing our send-url.)

I have no idea how to fix this cleanly and i believe there's no drupalish way to do so.

simon georges’s picture

Status: Needs work » Closed (won't fix)

No fix will happen in 6.x-1.x, nobody has any idea how to do it cleanly, and no action has been done on this issue in a year... closing. Please reopen if you still have trouble with the latest version of Simplenews.