Alright, so we run Vtiger CRM internally - the open source version. It's awesome for being able to muck around with, without the need to do any actual coding.
However, I have one feature I would really like to explore a bit more and I think it is the code that is either buggy or I am doing the wrong thing with it.
So we have a "Billing" module, it should receive an email (which we send in HTML format), read the body and extract the body, then convert this to a PDF.
I really don't know what I am looking at, but what I did was just go through the script (i know which one it is because there is a cron set to run) and add a bunch of "echo" statements to try and find where it stops working.
Script: https://pastebin.com/BBSSPTYL
From what I can see the whole script executes correctly (and I get the resulting email with PDF attached as I should), however the issue is the PDF is always blank.
So looking back through the echo output there is the lines:
if (strpos($mail_subject, '#8369') !== false) {
echo 'mail subject has hash #8369';
echo '<br><br>';
$mailbody=imap_fetchbody($inbox,$email_number,2);
echo 'raw email body input...<br><br>'.$mailbody;
echo '<br><br>';
$msub=$mail_subject;
$x=explode("#",$msub);
$accno=$x[1];
$mailbody=quoted_printable_decode($mailbody);
Am i right in thinking that is the bit where the email body is being read?
And if i do this echo 'raw email body input...<br><br>'.$mailbody; it should print the actual email body which should be a HTML file.
At the moment this echo statement just prints a blank line so I think that is why I am getting a blank PDF because there isn't actually there to be converted.
As I said, have no proper idea what I am looking at, but any nudge in the right direction would be awesome!
Edit: that code didn't format properly. fixed.