Error when emailing invoice

Kovah, thanks for adding it into the developer portal.

Musa: I’ve taken your suggestions and applied it… But it was not successful. Still receiving the same error.

@Kovah Having read through some other threads on this same issue, I think it may have to do with badly formed HTML in the email. I tried to make the HTML fairly strict (paragraph marks surrounding text) and it worked fine. But when I think I had empty paragraph tags (with nothing in between the open and close tags), it seemed to through that error. Might be worth testing that scenario.

Same problem here, appeared when i updated to the latest 1.5.4 (from 1.5.3 version).
I’m new to Invoiceplain and i love it, installed it just a week ago and it was running smoothly but now this happened. Checked what people above suggest but it doesn’t seem to help. Any help much appreciated.

A PHP Error was encountered

Severity: Warning

Message: unlink(/usr/www/users/casabqsejr/invoice/uploads/temp/mpdf): Is a directory

Filename: helpers/mpdf_helper.php

Line Number: 117

Backtrace:

File: /usr/www/users/casabqsejr/invoice/application/helpers/mpdf_helper.php
Line: 117
Function: unlink

File: /usr/www/users/casabqsejr/invoice/application/helpers/pdf_helper.php
Line: 254
Function: pdf_create

File: /usr/www/users/casabqsejr/invoice/application/helpers/mailer_helper.php
Line: 92
Function: generate_quote_pdf

File: /usr/www/users/casabqsejr/invoice/application/modules/mailer/controllers/Mailer.php
Line: 208
Function: email_quote

File: /usr/www/users/casabqsejr/invoice/index.php
Line: 327
Function: require_once
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /usr/www/users/casabqsejr/invoice/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: helpers/url_helper.php

Line Number: 564

Backtrace:

File: /usr/www/users/casabqsejr/invoice/application/modules/mailer/controllers/Mailer.php
Line: 213
Function: redirect

File: /usr/www/users/casabqsejr/invoice/index.php
Line: 327
Function: require_once

I’ve notice it’s only the Quotes that does this problem for me i did disable all templates and its still not working but when i send a invoice it works fine. please assist if possible. Thanks

i made a temporary fix on directory “/application/helpers/mpdf_helper.php” i comment out the line 117 will have to see in the logs for more errors hope it works for someone who find more errors like this.

// unlink(UPLOADS_FOLDER . ‘temp/’ . $file);

Found a solution with some help of good friends hope it works for you

under directory “/application/helpers/mpdf_helper.php” made some adjustments

$mpdf->Output(UPLOADS_FOLDER . ‘temp/’ . $filename . ‘.pdf’, ‘F’);

    // Housekeeping
    // Delete any files in temp/ directory that are >1 hrs old
    $interval = 3600;
    if ($handle = @opendir(preg_replace('/\/$/', '',UPLOADS_FOLDER . 'temp/'))) {

        while (false !== ($file = readdir($handle))) {
          if (($file != '..') && ($file != '.') && !is_dir($file) && ((filemtime(UPLOADS_FOLDER . 'temp/' . $file) + $interval) < time()) && (substr($file, 0, 1) !== '.') && ($file != 'remove.txt')) { // mPDF 5.7.3

              unlink(UPLOADS_FOLDER . 'temp/' . $file);
            }
        }
        closedir($handle);
    }

Hello @Kovah

Thank you for your release. I saw your fixed a bug with the quotes sending emails. But still the issue is present when i’m trying to send the quote invoice.

A PHP Error was encountered

Severity: Warning

Message: unlink(/uploads/temp/mpdf): Is a directory

Filename: helpers/mpdf_helper.php

Line Number: 133

Backtrace:

File: /application/helpers/mpdf_helper.php
Line: 133
Function: unlink

File: /application/helpers/pdf_helper.php
Line: 257
Function: pdf_create

File: /application/helpers/mailer_helper.php
Line: 110
Function: generate_quote_pdf

File: /application/modules/mailer/controllers/Mailer.php
Line: 208
Function: email_quote

File: /index.php
Line: 327
Function: require_once

A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$invoice_date_due

Filename: helpers/template_helper.php

Line Number: 30

Backtrace:

File: /application/helpers/template_helper.php
Line: 30
Function: _error_handler

File: /application/helpers/mailer_helper.php
Line: 114
Function: parse_template

File: /application/modules/mailer/controllers/Mailer.php
Line: 208
Function: email_quote

File: /index.php
Line: 327
Function: require_once

An uncaught Exception was encountered

Type: Error

Message: Call to a member function format() on boolean

Filename: /application/helpers/date_helper.php

Line Number: 86

Backtrace:

File: /application/helpers/template_helper.php
Line: 30
Function: date_from_mysql

File: /application/helpers/mailer_helper.php
Line: 114
Function: parse_template

File: /application/modules/mailer/controllers/Mailer.php
Line: 208
Function: email_quote

File: /index.php
Line: 327
Function: require_once

Is their a quick fix to do?

PS: it’s only with the quote invoice, normal invoice can be send by email as normal.
PSS: Above “solution” of @Chris1 does not fix it. I just tried that.

Just to expand on Chris1’s post…

I basically commented out the following code

 // Housekeeping
        // Delete any files in temp/ directory that are >1 hrs old
        /*$interval = 3600;
        if ($handle = @opendir(preg_replace('/\/$/', '', './uploads/temp/'))) {
            while (false !== ($file = readdir($handle))) {
                if (
                    $file && !in_array($file, ['..', '.', 'remove.txt'])
                    && !is_dir($file) && (substr($file, 0, 1) !== '.')
                    && (filemtime('./uploads/temp/' . $file) + $interval) < time()) {
                        unlink(UPLOADS_FOLDER . 'temp/' . $file);
                }
            }
            closedir($handle);
        } */

It looks like this piece of code clears any quote pdf’s stored in the temp directory when sending a quote? I will do that manually for now. Quote email seems to send fine now.

I still have this error. Don’t know why?
Is v1.5.5 fixed this?

1.5.5 will fix this but you may have to wait for the release as I have no time for reviews and a new release.

Hi. No, i don’t think the v1.5.5 is fixing it. Actually, there is no error while sending invoice, but for me it appearing while sending quote only. Is there is any fix for that ?

Hi,
When you upgraded to 1.5.5, did you also upgrade to PHP7x (not 7.2) and install/enable the required php extensions?
d

I upgrade to 1.5.5 and my PHP is PHP 7.1.13, all extensions enable that InvoicePlane required. But I always send quotation error. don’t know why?

After upgrading, did you update the tables by re-renabling “setup” in ipconfig.php then viditing invoiceplaneurl/indes.php/setup/?

Please enable debug mode and post the output to the IP paste site (remove any full URLs and base paths. Instructions for enabling debug can be found in the FAQ.

I didn’t mention about the upgrade. I downloaded the latest version and set up a new site with instruction.
But when send email for quotation it have an error like @groupewibi
Do I need hard code for this error to send email because I need my business running smoothly?

Have you setup correctly the permission for the folder (especially /uploads ?)

Moreover have you the folder mpdf in uploads/temp like specified in the error ?

Edit : I try to reproduce the errors but nothing happens for me
In the application\views\quote_templates\pdf you can confirm that you have one file/template right ?

Edit2 : what I can tell you for sure is that the block which leads to the first error is removed/fixed at the next update which should be released soon normally :slight_smile:

I followed instruction, so the permission for folders or files is correct.
The folder mpdf existed in uploads/temp like the error that we discuss from the beginning of this topic.
And in application/views/quote_templates/pdf have the default template of InvoicePlane.

The only thing I can tell you is
https://community2.invoiceplane.com/t/topic/5702/4

Wait for the next release it should be fixed :confused:

I can’t reproduce the bugs on my side so it’s difficult to find the correct fix :slight_smile:

1 Like

Hi, I just installed InvoicePlane, and I also get this error

"A PHP Error was encountered

Severity: Warning

Message: unlink(/home1/dmuirragui/public_html/cotizador/uploads/temp/mpdf): Is a directory

Filename: helpers/mpdf_helper.php

Line Number: 133

Backtrace:

File: /home1/dmuirragui/public_html/cotizador/application/helpers/mpdf_helper.php
Line: 133
Function: unlink

File: /home1/dmuirragui/public_html/cotizador/application/helpers/pdf_helper.php
Line: 257
Function: pdf_create

File: /home1/dmuirragui/public_html/cotizador/application/helpers/mailer_helper.php
Line: 110
Function: generate_quote_pdf

File: /home1/dmuirragui/public_html/cotizador/application/modules/mailer/controllers/Mailer.php
Line: 208
Function: email_quote

File: /home1/dmuirragui/public_html/cotizador/index.php
Line: 327
Function: require_once
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home1/dmuirragui/public_html/cotizador/vendor/codeigniter/framework/system/core/Exceptions.php:271)

Filename: helpers/url_helper.php

Line Number: 564

Backtrace:

File: /home1/dmuirragui/public_html/cotizador/application/modules/mailer/controllers/Mailer.php
Line: 213
Function: redirect

File: /home1/dmuirragui/public_html/cotizador/index.php
Line: 327
Function: require_once"

Thanks in advance for the help to fix it

I get the error page when sending a quote but the email does actually send out the quote