Files: 
CommentFileSizeAuthor
#26 SMTP-1442514-20.patch1.29 KBtetter36
#19 patch.txt1.15 KBmoonberry
#12 smtp-1442514-12.patch1.14 KBtobiasb
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]
#8 1442514-8.patch1.05 KBkillua99
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1442514-8.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]
#1 mimemail-attachment-1442514-1.patch850 bytesmavimo
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch mimemail-attachment-1442514-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Comments

mavimo’s picture

Issue tags:+mimemail, +attachment
StatusFileSize
new850 bytes
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch mimemail-attachment-1442514-1.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

Improved patch to support sending mail using filepath and filecontent.

Into mimemail we can send mail using:

<?php
  $params
= array(
   
'attachments' => array(
     
0 => array(
       
'filecontent' => '<?xml version="1.0" encoding="UTF-8"? ><test><item /></test>',
       
'filename' => 'test.xml',
       
'filemime' => 'text/xml',
      ),
     
1 => array(
       
'filepath' => 'public://test.xml',
       
'filename' => 'test.xml',
       
'filemime' => 'text/xml',
      ),
    ),
  );
?>

in accord with mimemail docs.

felixvang’s picture

I'm sorry, I'm new to these stuff. What should I do with this .patch file or where should I add it?

gabrielu’s picture

Status:Active» Reviewed & tested by the community

Thanks for the patch @mavimo , patch #1 worked like a charm for me.

I think this should be ported to the next release.

Gabriel

wundo’s picture

Status:Reviewed & tested by the community» Fixed

Commited, thanks! :)

killua99’s picture

Version:7.x-1.0-beta1» 7.x-1.x-dev
Category:feature» support
Status:Fixed» Active

When I send a attachment application/pdf mime file it's apear.

The data could not be saved because the destination /tmp/smtpc856Ac is invalid. This may be caused by improper use of file_save_data() or a missing stream wrapper.

File smtp.mail.inc line 432
version = "7.x-1.0-beta2+3-dev"

killua99’s picture

Ok I can't do a patch cause I'm not using git (sorry) but you can follow this instruction.

Replace all the attachment_new_filename for this.

              $attachment_new_filename = drupal_tempnam('temporary://', 'file');
              $file_path               = file_save_data($attachment, $attachment_new_filename, FILE_EXISTS_RENAME);
              $real_path               = drupal_realpath($file_path->uri);

              if (!$mailer->AddAttachment($real_path, $file_name)) { // , $file_encoding, $filetype);
  

This is a good use when you creat a tmp name with tmp directory.

tobiasb’s picture

I get this error with mimemail (rule) and smtp

Notice: Undefined index: filename in SmtpMailSystem->mail() (Line 455 of sites/all/modules/contrib/smtp/smtp.mail.inc).
Notice: Undefined index: filemime in SmtpMailSystem->mail() (Line 455 of sites/all/modules/contrib/smtp/smtp.mail.inc).
killua99’s picture

Status:Active» Needs review
StatusFileSize
new1.05 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1442514-8.patch. Unable to apply patch. See the log in the details link for more information.
[ View ]

An issue failing with temporary files.

killua99’s picture

Category:support» bug

Change status.

dandaman’s picture

Status:Needs review» Reviewed & tested by the community

The patch in #8 definitely fixed my problem with temporary files from the MIME not saving correctly. Thanks for the patch, killua99!!

wundo’s picture

Status:Reviewed & tested by the community» Fixed

Last patch was committed.

tobiasb’s picture

Status:Fixed» Needs review
StatusFileSize
new1.14 KB
PASSED: [[SimpleTest]]: [MySQL] 0 pass(es).
[ View ]

Ok my bug is not solved with the latest release.

When you send a html-email via rules to use the attachments, mimemail creates only an array with the filepath key, no filename or something.

rules_action_mimemail -> drupal_mail -> mimemail_mail
(attachment is a string) -> ... -> attachment is an array.

cgdrupalkwk’s picture

Having the same issue as #7. Patch in #12 did not work to solve.

tobiasb’s picture

@cgdrupalkwk then your rule is wrong ;-)

killua99’s picture

Did you test send an attachment without using rules? Because this one seen another kind of issue but with the link of attachment. You use Rules + mimemail + smtp. This issue only use mimemail and smtp. Better to open a new one?

tobiasb’s picture

Ok lets say the patch is a followup. ;-)

chrbak’s picture

I am having a similar problem with the attachment files. I don't use rules only the mimemail with the simplenews module and the error that i am getting is the bellow:

Fatal error: Cannot use object of type stdClass as array in C:\inetpub\wwwroot\sites\all\modules\smtp\smtp.mail.inc on line 449

The solution i found is to delete the lines 447 to 456 and the problem solved. Now i can send newsletters with the attached files.

chrbak’s picture

I found that at line 449 tries to check a variable that is actualy an oblect like the bellow:

$ Object
(
    fid = String(4) "2772"
    uid = String(4) "1235"
    filename = String(45) "filename.pdf"
    uri = String(69) "public://(...)/filename.pdf"
    filemime = String(15) "application/pdf"
    filesize = String(6) "372540"
    status = String(1) "1"
    timestamp = String(10) "1365774040"
    rdf_mapping => Array (0)
    (
    )
)
moonberry’s picture

StatusFileSize
new1.15 KB

I have same problem as #17 with sending attachements, here is a patch for dev version 2013-Mar-17.

MarcusOaten’s picture

For some reason I seem to get 2 (duplicate) attachments when using rules to send attachments, with both the patch and current Dev version.

killua99’s picture

+++ b/smtp.mail.inc 2013-04-29 12:22:37.333324000 +0200
@@ -441,12 +441,14 @@
+        if (!is_object($attachment)) {

Why you need to check is not a object? I mean with an isset or !empty you have done that kind of confirmation.

kolafson’s picture

Had the same issue as #7 and patch in #12 solved it.

jurgenhaas’s picture

Patch #12 works fine for me.

wundo’s picture

Status:Needs review» Fixed

Patch from #12 was committed, thanks ;)

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

tetter36’s picture

Version:7.x-1.x-dev» 7.x-1.2
Issue summary:View changes
Status:Closed (fixed)» Active
StatusFileSize
new1.29 KB

I couldn't send out emails using SMTP, Simplenews, Mimemail, and Elysia Cron. I was receiving the following error in my logs:

Unexpected termination of cron channel default, aborted. Last job executed: simplenews_cron

I then looked in the apache error log and saw this:
PHP Fatal error:  Cannot use object of type stdClass as array in /var/www/financesociety/sites/all/modules/smtp/smtp.mail.inc on line 469,

Attached is the patch I used to fix the issue. After adding the patch, I didn't get any more errors in the apache log and the emails began sending without the "Unexpected termination of cron channel default, aborted. Last job executed: simplenews_cron" error.

capono’s picture

Thanks @tetter36, patch #26 works fine for me.

Allerby’s picture

I had a similar problem using Webform2pdf, SMTP and Mimemail. #26 worked for me - however I had to remove the filecontent object reference in the if statement from line 469 and 472. Not a great solution but it did the trick. My final solution looked like this:

<?php
   
if (isset($message['params']['attachments'])) {
      foreach (
$message['params']['attachments'] as $attachment) {
        if (isset(
$attachment)) {
         
$mailer->AddStringAttachment($attachment->filecontent, $attachment->filename, 'base64', $attachment->filemime);
        }
        if (isset(
$attachment)) {
         
$filename = isset($attachment->filename) ? $attachment->filename : basename($attachment->filepath);
         
$filemime = isset($attachment->filemime) ? $attachment->filemime : file_get_mimetype($attachment->filepath);
         
$mailer->AddAttachment($attachment->filepath, $filename, 'base64', $filemime);
        }
      }
    }
?>