I was sending out an e-mail where I was generating a PDF, rendering it in a string, and then passing it to the mail function. I found that this was not working correctly within the smtp.mail.inc file. After much debugging, it seems to be these two lines:

              $attachment_new_filename = tempnam(realpath(file_directory_temp()), 'smtp');
              $file_path               = file_save_data($attachment, $attachment_new_filename, FILE_EXISTS_RENAME);

I found that it now works with this change:

              $attachment_new_filename = tempnam(realpath(file_directory_temp()), 'smtp');
              $file_path               = file_unmanaged_save_data($attachment, $attachment_new_filename, FILE_EXISTS_RENAME);

The reason the initial doesn't work is because the file_save_data() function expects a well-formatted stream wrapper and will save it into public or something.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Simon Georges’s picture

Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Needs review
FileSize
640 bytes

I don't know if there's any reason to indicate Drupal to have this file managed, so it could make sense even without the bug you're reporting.

Any way, I don't have any test case, so I just provide the patch as a way for the maintainer to test it quickly (and to give some visibility to the issue). All credits goes to dandaman if this is indeed the right fix for the issue.

This patch is part of the #1day1patch initiative.

DamienMcKenna’s picture

Issue summary: View changes
FileSize
640 bytes

Rerolled.

Anonymous’s picture

Worked for me. Looks good on this one.

wundo’s picture

Status: Needs review » Closed (outdated)

Closing very old (dead) issues, if you think this is still relevant please re-open.