Closed (fixed)
Project:
Storm
Version:
6.x-1.x-dev
Component:
Storm Invoice
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Aug 2009 at 01:26 UTC
Updated:
2 Sep 2009 at 13:40 UTC
In some installations of Storm, the function "Send PDF via e-mail" does not attach the PDF invoice to the email that is sent.
Sample email:
Return-path: <apache@org.net>
Envelope-to: postmaster@org.net
Delivery-date: Sat, 08 Aug 2009 21:11:45 -0400
Received: from mail by org.net with spam-scanned(Exim 4.69 #1 (chianna Linux 0.6))id 1MZwwr-0000bt-FQ; Sat, 08 Aug 2009 21:11:45 -0400
X-Spam-Checker-Version: SpamAssassin 3.2.1-gr1 (2007-05-02) on chianna
X-Spam-Level:
X-Spam-Status: No, score=0.0 required=5.0 tests=UNPARSEABLE_RELAY
autolearn=ham version=3.2.1-gr1
Received: from apache by org.net with local(Exim 4.69 #1 (chianna Linux 0.6))id 1MZwwr-0000bq-Ct; Sat, 08 Aug 2009 21:11:45 -0400
To: customer@business.com
Subject: Invoice from Lizard's Lounge
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=d3dee2b6be9273153307cdb44f6d561d
Content-Transfer-Encoding: 8Bit
X-Mailer: Drupal
Errors-To: info@org.net
From: admin<webmaster@org.net>
Message-Id: <E1MZwwr-0000bq-Ct@org.net>
Sender: apache <apache@org.net>
Date: Sat, 08 Aug 2009 21:11:45 -0400
--d3dee2b6be9273153307cdb44f6d561d
Content-Type: text/plain; charset=UTF-8; format=flowed;
Thank you!
--d3dee2b6be9273153307cdb44f6d561d--
Comments
Comment #1
Magnity commentedJust a few queries:
- From the problematic installation, does it work if you send to a different email address?
- Does it work if you send a different invoice?
- Are there any log entries, error messages, etc etc etc?
Comment #2
Magnity commentedChanging status.
Comment #3
squ1rr3l commentedThe email always goes out, and yes, I've tried several email addresses. Both the destination and the "send me a copy" emails are sent and received.
I have several invoices, and just tried an invoice with just 1 item, same result.
It appears to just silently fail - I can't find any indication in apache logs or anywhere else of an error.
Comment #4
Magnity commentedOK, a few more questions...
- Have you had this working on your installation before?
- Which other modules do you have enabled?
- Are you using the default drupal mail handlers, i.e. are you using SMTP module, or anything like that?
- If you use the demo site (which works for me), at the same email address - does that work?
- The headers above indicate a multipart message - of which the first is the plaintext covernote - is there anything in the second part?
Also - has anyone else had this problem?
Comment #5
squ1rr3l commentedAnswers:
- Have you had this working on your installation before?
No, it's never worked, AFAICT
- Which other modules do you have enabled?
All of the Storm modules are enabled, although I don't use them all. Not sure if you're looking for other modules, there are not many extra ones installed, just CCK and VersionControl.
- Are you using the default drupal mail handlers, i.e. are you using SMTP module, or anything like that?
Yes, it's just basic Drupal 6.13 install. No mail modules at all. It's sitting on a Gentoo Linux box with Exim.
- If you use the demo site (which works for me), at the same email address - does that work?
There's a demo site? Okay - I've never used it before. Yes, it works fine, as expected. The only difference I can see looking at the email source is that the working one actually has the 2nd section with the uuencoded PDF.
- The headers above indicate a multipart message - of which the first is the plaintext covernote - is there anything in the second part?
No, it's exactly as shown above, ending after the first part. Note the part separator at the end has the "--" at the back, indicating there are no more parts. In the file from the demo site it looks like this:
Also - has anyone else had this problem?
I'd like to know that too! This may be one of those "it's just me" issues, and it make little sense to hold things up if that's the case.
Where is the code that performs that function? I've dug around a bit, but I haven't really done any Drupal development (and only a little bit of PHP), so I don't really know where to look and couldn't find it.
... Squirrel.
Comment #6
Magnity commentedLets wait to see if anyone else is having this issue too then - I can't see from your post any reason why it should go wrong in this way.
The code is mainly in storminvoice.admin.inc (from memory - hope that's correct).
Comment #7
Mark_Watson27 commentedI've tested this on latest dev using Drupal 6.13 and get the same issue.
1) I've never used the feature before so cannot say if it's ever worked before
2) Administration Menu, Advanced Help, CCK, Date, Devel, Node Import, Popups API, Storm, Storm QT, Views
3) Default mail handlers (it doesn't seem to like SMTP Auth module)
4) Not tired demo site
5) Same as above no second part
6) Yes me :)
I'll have a play at some point and see if I can narrow it down.
Cheers
Mark
Comment #8
Mark_Watson27 commentedOkay, I think I see where this is stumbling up....
In
storminvoice.admin.incthe function that is called when submitting the send isstorminvoice_send_form_submit.This function gets a variable for the PDF File Name
$pdffile = variable_get('storminvoice_email_pdf_file_path', '');and checks it before attaching the fileif($pdffile){. However this never gets set until the function_storminvoice_report_file_pdfis called!Quick work-around rem out the check and send two test PDFs the second should come through okay
After removing the check, the first time you send the PDF the variable will get set. The second time you send it it's correctly there to attach!
I haven't got time to write the patch at the mo and have no idea how this is working on a fresh system as I can't spot where those variables are being set without calling that function.
Thanks
Mark
Comment #9
homoludens commentedthose variables are set in function _storminvoice_report_file_pdf at the end of storminvoice.admin.inc file.
i will, also, search for solution. i will, probable, need some time to catch up with other things, but this is high on mine todo list.
Comment #10
Magnity commentedOK - it looks like I had the variables left in the system. On manually removing one of the variables, I get back to the situation that everyone else is having.
I wonder if this is due to the changes we made to the function prior to putting it in regarding not saving the invoice in the filesystem prior to emailing?
Comment #11
Mark_Watson27 commented@homoludens, yeah kinda figured that with my posting in #8 :)
Seriously though I don't think this will take much getting around, it's just wrong logic at the moment.
However it did point out to me that we're not checking the filename that's constructed. It should really be checked for invalid characters etc as per transliteration (http://drupal.org/project/transliteration)
@magnity: what were the changes, at first glance I'd say that we'd just need to check that we can PDF, but would need to take more time with it before confirming.
Cheers
Mark
Comment #12
Magnity commentedSee #450360: Automatic E-Mail Invoicing comments #19 - #21.
Comment #13
Mark_Watson27 commentedChanging the function to:
Seems to have done it for me, i.e. getting rid of the if and moving the PDF generation to the top.
I'm going to work on abstracting the PDF transformation so we're not duplicating code.
Comment #14
Magnity commentedI think @homoludens knows this bit of the code best - so i'd like to get a review from him. I'll be testing the code changes myself later on today or tomorrow.
Comment #15
Magnity commentedCommitted that fix.
A couple of issue sprouting from here though:
- #553556: Combine PDF invoice generation functions
- #553560: Tax fields blank in PDF invoice sent by email