Unable to Email Invoice (self-hosted)

Hi there…
As far as I know, I’ve got everything set up fine. I can send test emails, which is set up through SMTP.

When I try to send an invoice, clicking the Send Invoice button causes the buttons, etc., to grey out, as though its doing something, but nothing else happens. The email is not sent, and the Send Email lightbox just sits there until I exit the screen. Although, if I leave it long enough (quite a few minutes), eventually a message pops up, saying:

There was an error saving your invoice
Service Unavailable

So far that messsage has only appeared once. Most times it just sits there for many minutes, unless I eventually close the panel.

I suspect this is a permissions issue. I’ve already had some permissions issues, which I resolved (see this thread)

Are there additional folders I need to set specific permissions on?

Also, there is no related entry in the log at ./storage/logs/laravel-error.log

I’ve figured out that if I turn off Attach PDF, it will send without issues.

I have installed phantomjs on the server, and it is in /usr/bin/phantomjs

I added that path to the .env file.

Is there anything else I might need to do? Permissions, for instance, that are in some way related to attaching PDF files?

I’d suggest checking the troubleshooting steps here:

http://docs.invoiceninja.com/en/latest/configure.html#troubleshooting

Also, check the web server error logs. Maybe it’s failing to write to laravel-error.log?

Thanks. I went through the Troubleshooting list. And the only issue I came across was that testing the test.pjs file gives the following output:

\n{
    "console": []

I have no idea what output I am meant to get, but I gather the above is not it.
Phantomjs worked fine when I do a simple test, outputting “Hello world” from a test file I set up.

But I gather phantomjs needs to save the file it is generating, and I suspect that’s the issue. That it doesn’t have the necessary permission to save it.

There are other entries in the laravel error log, but nothing since many hours ago when I was trying to get things set up.

I’ll take a look in the server log

The error generated in the apache2 error log is:

[Thu Mar 15 09:46:10.885964 2018] [proxy_fcgi:error] [pid 98593:tid 139646281242368] (70007)The timeout specified has expired: [client IPADDRESS:62501] AH01075: Error dispatching request to : (polling), referer: https://invoicing.DOMAINNAME.org.nz/invoices/1/edit

Doesn’t really give much away, does it? :slight_smile:

I’d suggest checking if disabling HTTPS helps.

Thanks.

Same issue occurs when running over http://

How can I find out what folder phantomjs would be attempting to save the PDF file to before it’s attached to the email?

PhantomJS doesn’t save to a folder, the output is directly attached to the email.

Oddly, it’s now behaving as if the email is sent. Gives a confirmation saying it was sent, and does not hang, etc. Yet it’s not sending anything.

Also, with no error in the log.

Additionally, I’ve also now switched over to using an online phantomjs account. Made no difference. Both before and after that setting change, it’s been appearing as those it has sent the message, but hasn’t. :frowning:

Have you run php artisan config:cache?, you’d need to clear the cache if you make change to the .env file.

You may want to test with a different email provider.

Thanks for the suggestion.
After running that command, it looks like my .env file is almost completely cleaned out. Most of the settings have no value, and the declarations I’d added have gone.
Is that meant to occur?

APP_URL=https://invoicing.MYDOMAIN.org.nz
APP_DEBUG=false
REQUIRE_HTTPS=true
DB_TYPE=mysql
DB_HOST=localhost
DB_DATABASE=ninja
DB_USERNAME=ninja
DB_PASSWORD=ninja
MAIL_DRIVER=smtp
MAIL_PORT=587
MAIL_ENCRYPTION=tls
MAIL_HOST=
MAIL_USERNAME=
MAIL_FROM_NAME=
MAIL_FROM_ADDRESS=
MAIL_PASSWORD=
MAILGUN_DOMAIN=
MAILGUN_SECRET=

Also, it appears I can no longer save settings in the app.
I enter them in, and hit save, and they don’t save.

Well, actually, I see they do end up in the .env file, but they don’t show in the app. Very odd.

How could that be?

That command shouldn’t affect the .env file, can you replicate the problem?

Not sure… you may want to edit the file manually rather than use the system settings page.

I put in the settings manually, to the .env.
Tried running, php artisan config:cache again.
It gave the same output, namely:

Configuration cache cleared!
Configuration cached successfully!

This time the .env file remained in tact.

When I returned to the app, it had logged me out.
When I view the system settings, the email sending settings are blank. Although I can see the settings in the .env file.
When I try to do various things (like editing an existing invoice), I get the error: Whoops, looks like something went wrong.

Looks like the situation is going to bad to worse.

Pretty much everything is now giving me that error:

Whoops, looks like something went wrong.

Even logging in.

Are there new errors in laravel-error.log?

I don’t think config:cache erased the .env file, are you certain the file was set before? If you’ve only used the system settings page maybe it failed to write to the file which would explain why email wouldn’t work correctly.

To be clear you shouldn’t run php artisan config:cache, if you’ve run it you need to run php artisan config:clear and then not run config:cache again.

There are lots of errors… Such as:

[2018-03-15 10:50:39] production.ERROR: ***Illuminate\Contracts\Encryption\DecryptException*** [0] : /opt/bitnami/apps/invoicing/htdocs/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid.  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"POST","url":"https://invoicing.MYDOMAIN.org.nz/login","previous":"https://invoicing.MYDOMAIN.org.nz/login","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":1,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-03-15 10:51:06] production.ERROR: ***Swift_RfcComplianceException*** [0] : /opt/bitnami/apps/invoicing/htdocs/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/Headers/MailboxHeader.php [Line 345] => Address in mailbox given [] does not comply with RFC 2822, 3.6.2.  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"POST","url":"https://invoicing.MYDOMAIN.org.nz/setup","previous":"https://invoicing.MYDOMAIN.org.nz/settings/system_settings","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":2,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-03-15 10:51:19] production.ERROR: ***ErrorException*** [0] : /opt/bitnami/apps/invoicing/htdocs/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php) (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php)  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"GET","url":"https://invoicing.MYDOMAIN.org.nz/invoices/4/edit","previous":"https://invoicing.MYDOMAIN.org.nz/invoices","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":3,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-03-15 10:51:24] production.ERROR: ***ErrorException*** [0] : /opt/bitnami/apps/invoicing/htdocs/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php) (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php)  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"GET","url":"https://invoicing.MYDOMAIN.org.nz/invoices/4/edit","previous":"https://invoicing.MYDOMAIN.org.nz/invoices/4/edit","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":4,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-03-15 10:53:56] production.ERROR: ***ErrorException*** [0] : /opt/bitnami/apps/invoicing/htdocs/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php) (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php)  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"GET","url":"https://invoicing.MYDOMAIN.org.nz/invoices/4/edit","previous":"https://invoicing.MYDOMAIN.org.nz/invoices/4/edit","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":5,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-03-15 10:54:12] production.ERROR: ***ErrorException*** [0] : /opt/bitnami/apps/invoicing/htdocs/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid. (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php) (View: /opt/bitnami/apps/invoicing/htdocs/resources/views/partials/email_templates.blade.php)  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"GET","url":"https://invoicing.MYDOMAIN.org.nz/invoices/2/edit","previous":"https://invoicing.MYDOMAIN.org.nz/invoices","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":6,"is_console":"no","is_api":"no","db_server":"mysql"} []
[2018-03-15 10:56:23] production.ERROR: ***Illuminate\Contracts\Encryption\DecryptException*** [0] : /opt/bitnami/apps/invoicing/htdocs/bootstrap/cache/compiled.php [Line 13563] => The MAC is invalid.  {"context":"PHP","user_id":1,"account_id":1,"user_name":"Jonathan Evatt","method":"POST","url":"https://invoicing.MYDOMAIN.org.nz/login","previous":"https://invoicing.MYDOMAIN.org.nz/login","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","ip":"125.236.182.4","count":1,"is_console":"no","is_api":"no","db_server":"mysql"} []

I ran php artisan config:cache for the first time when you mentioned it.
The .env file reset to a having almost no settings except the domain name and the default DB settings. All other declarations where `…=" with no value.

<blockquote>Have you run php artisan config:cache?, you’d need to clear the cache if you make change to the .env file.</blockquote>

Based on the above, I ran it a second time, after I manually added the settings back into the .env file. I had understood (incorrectly, by the sounds of it) that this was required after making changes to it.

Am I correct in understanding that when I make manual changes to the .env file I should run php artisan config:clear ?

Btw … What was the purpose (function) of the prior command? php artisan config:cache ?

I gather there were some settings in the .env file that I have not recalled from memory, which are fundamental to the app functioning.

Any clue as to what they might be?
Or how I simply restart this thing from scratch?