For a simplenews newsletter, I have a file attached for each issue. The URL to the attached file that is sent in the email and the link provided in the submitted node generate 404 errors.

Any help?

Thanks
mrweaver

CommentFileSizeAuthor
#11 drupal_wrap_mail_line.diff777 bytesDave Cohen
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Sutharsan’s picture

Status: Active » Closed (fixed)

No activity, closing the issue.

redsky’s picture

Version: 5.x-1.3 » 6.x-1.0-rc6
Status: Closed (fixed) » Active

I found the same thing, what I found is files with spaces in them were getting "double spaces" in the generated url, but just in the email, not the link on the website.

redsky’s picture

Category: support » bug

I'm changing this to a bug report. Can anyone help?

When files are attached, the email actually shows the attachment in two ways. First it is physically attached to the email - great this works. Second there is an "Attachments" section at the bottom that lists files and their sizes with links to the files on the website. This looks just like the website does, however the link does not work. It adds a second space (%20) for one of the spaces in the file name. Even stranger it is not consistent which one of the spaces is doubled, in one file the second space was doubled, in another the third space was doubled.

For example, on this node: http://www.bedfordscouts.ca/cubs/posting/1st-bedford-b-cub-pack-fall-camp

The email generated the link incorrectly: (notice after the word Bedford in the file name - two %20)
The website generated the link like correctly. (notice after the word Bedford in the file name - one space)

Email HTML:
<a href="http://www.bedfordscouts.ca/files/1st%20Bedford%20%20
Cub%20Pack%20-%20Fall%20Camp%20-%20Info%20Slip.pdf">1st Bedford Cub Pack - Fall Camp - Info  
Slip.pdf</a>

Website HTML
<a href="http://www.bedfordscouts.ca/files/1st Bedford Cub Pack - Fall Camp - Info Slip.pdf">1st Bedford Cub Pack - Fall Camp - Info Slip.pdf</a>

Honestly I'd prefer to only have real attachments and not links to the attachments in the emails but if they're going appear as links they need to work.

Thanks,
Chris

redsky’s picture

I just noticed a bit more. Below is the whole HTML source for the attachments table from the email. Notice that the double %20 appear on the space next to the line break. I don't know what this means but more knowledge might someone help me out here.

<table id="attachments" class="sticky-enabled">
<thead><tr>
<th>Attachment</th>
<th>Size</th> </tr></thead>
<tbody>
<tr class="odd">
<td><a href="http://www.bedfordscouts.ca/files/1st%20Bedford%20%20
Cub%20Pack%20-%20Fall%20Camp%20-%20Info%20Slip.pdf">1st Bedford Cub Pack - Fall Camp - Info  
Slip.pdf</a></td>

<td>16.05 KB</td> </tr>
<tr class="even">
<td><a href="http://www.bedfordscouts.ca/files/Cabin%20Camp%20%20
Gear%20List%20ALL.pdf">Cabin Camp Gear List ALL.pdf</a></td>
<td>98.15 KB</td>  
</tr>
<tr class="odd">
<td><a href="http://www.bedfordscouts.ca/files/How%20to%20make%20a%20%20
Tin%20Foil%20Dinner.pdf">How to make a Tin Foil Dinner.pdf</a></td>
<td>767.22  
KB</td> </tr>

</tbody>
</table>
Sutharsan’s picture

There is also a issue in the queue about converting spaces into %20. I'm not sure is these are simplenews or mime mail issues. Please check the mime mail issue queue too. and make sure you use latest development versions of both modules!

Sutharsan’s picture

Title: File attachments won't attach » Spaces in URLs converted to %20 and %20%20
Project: Simplenews » Mime Mail
Version: 6.x-1.0-rc6 » 6.x-1.0-alpha1

With this issue #291903: Properly convert file URLs to paths the space to %20 conversion was added mimemail. And from the size of the issue, this is a complex matter.

Moving this to mime mail.

marcvangend’s picture

Is there any progress on this issue? I have been looking at the _mimemail_url() function but I can't see why it would cause incorrect url's. Any thoughts, or suggestions where I should start fixing this bug?

sgabe’s picture

Title: Spaces in URLs converted to %20 and %20%20 » Soft-wrapping in drupal_wrap_mail() breaks URLs with white-spaces
Project: Mime Mail » Drupal core
Version: 6.x-1.0-alpha1 » 6.x-dev
Component: Miscellaneous » mail system

This is not a Simplenews, neither a Mime Mail but a core bug. The space character is unsafe, so it must always be encoded according to RFC 1738. This cause no problem at all. The problem is with the duplicate white-spaces. See, these links will not work even when the spaces are not encoded.

The source of the problem is that drupal_wrap_mail calls _drupal_wrap_mail_line which will do soft-breaks like \n and break the URL of an e.g Upload module attachment.

There is a similar issue #506112: wrong line wrapping on drupal_wrap_mail() in mail.inc so this could be a duplicate, but for now I just change the issue details and let somebody else to decide.

mcfilms’s picture

So the file name has a space in it: "kittens play.jpg" Mimemail correctly encodes the space as %20 but Drupal core is ALSO changing the space (white space) and including it. Is this the issue?

So, how does IMCE deal with this? Using CKeditor and IMCE you can upload just about anything you want, with as many spaces as you want. It all works. I'll tell you. It swaps a hyphen for the space right away and then uses that file name throughout. Is there a way that this way of handling image names can be ported over either to core or to mimemail?

Dave Cohen’s picture

I have the same problem.

I'd like some way to disable entirely any wrapping when the mail is HTML.
I'm using combination simplenews and mimemail.

Dave Cohen’s picture

Status: Active » Needs review
FileSize
777 bytes

Here's a change that does not change Drupal's default behavior in any way, yet allows admins to disable or change the length of line breaks.

To disable, I add this to settings.php:
$conf['drupal_wrap_mail_line'] = 0;

Status: Needs review » Needs work

The last submitted patch, drupal_wrap_mail_line.diff, failed testing.

STNyborg’s picture

I was not aware that I had the same problem until one of my newsletter readers complaint about failing URL links to attachments with spaces in the filenames.

I have searched high and low without any luck. Is anybody else aware about whether or not there is an updated workable solution to this problem?

As [#10] Dave Coven, I'm also using a combination of simplenews and mimemail.

Thanks,
STNyborg

eric.chenchao’s picture

I have also encountered this problem and spend couples of hours to find it out. For the time being I just increase the 77 into a big number like 100. I think text wrap is useful for plain-text email, but we can use CSS to control the width of content.

mattrweaver’s picture

I added a filefield to the newsletter content type to put my pdfs in and it works fine now.

walker2238’s picture

Subscribing. :( Sorry.

funkytraffic’s picture

I am not sure if this issue is related or I should open a new thread.

I am working with Mimemail and siplenews. I have an image included with an absolute path.

<img src="http://domain.xx/sites/subsite/files/image/image withspace.jpg">

_mimemail_url gives me a double %20%20 instead of the space in the first if-statement. I cannot figure out why.

All other filters are turned off, so mimemail must be the culprit. Either the function gets called twice in a wrong way, or somewhere else the space gets doubled?

funkytraffic’s picture

If drupal_wrap_mail is the culprit, why don't you write a new function mimemail_wrap_mail for this module?

Hanno’s picture

funkytraffic’s picture

Another workaround I use:

Use Filefield and Imagefield for files (if not external), use Filefield Path to clean URL and Insert to put them into the newsletter.

Spaces should not be in a newsletter file anyway, since we donnot know the OS of the receiver.

Though this does not work for external urls. In this case I save the newsletter, copy the URL and insert it again. For other user I put an advice in the header.

Anyway the file handling by Simplemail+Mimemail should be improved, allowing integration or extegration of files not on absolute or relative path but by option and allowing file name convention like in FileField Path.

wojtha’s picture

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 6 is no longer supported. If the issue verifiably applies to later versions, please reopen with details and update the version.