Inbound email creates cases, but doesnt parse template variables

Hi,

After getting my inbound email and autoreplies working, I started to notice that case creation autoreplies don’t have their variables parsed. I have tested email templates through the email module, and sent the same email template, related to the same case and this worked as expected, with the templates variables parsed like they should.

So now i am wondering what might cause this. Since I have browsed the forums and github issues for fixes, but was unable to find a solution. Is there anyone that can help me with this issue?

Regards,
David

You haven’t found a solution, but have you found a Github issue that corresponds correctly to your case?

Hi,
Yes the github issue #5944 seems to be the same problem, but i found that this fix was already implemented in the code. after trying to see if the functions of the EmailTemplateParser.php were called using both $GLOBALS['log'] and error_log(). i found that the application doesn’t seem to pass over te functions at all. since i did not find the strings i logged in neither the suitecrm.log nor the PHP logs.

So i dont really know what file i should look at in the first place anymore.

Thanks for your help in advance.

Regards,

David Born

What is your SuiteCRM version?

What about this fix, do you have it?

These variables that you’re hving trouble with - is it all variables, or just dropdown values (fields where you select the value from a list)?

Hi,
I am running SuiteCRM 7.11.12
It does seem similar, but in this post they are talking about emails through the campaign module, while my problem exists within the autoreplies. Email templates work when i send mails through the email module. With all the templates respective variables parsed like they should be. it only is on the autoreplies specifically, that the variables dont work.

All the variables used are from the “insert variables” dropdown, i have not added any variables that i created myself.

Sorry, I need to clarify, this is not what I was asking. My question is if the variable itself holds a value that is selected from a list. So for example a “name” variable is not a dropdown, but a “salutation” is, because you can only select from a list.

I dont think they are then, all the variables used in the email template are the same ones as in the default “case creation” template.

Hi,

I’m back trying to figure out whats wrong.
I have taken another look at the github issue that you’ve posted, and i noticed that the changes from the commit are already present in the version that i am running.

So I am still looking for a fix. I hope your expertise can help me out.

Regards,
David

Yes, if your variables aren’t from dropdowns, that fix would not be effective, you must be facing a different issue.

“My expertise” is not that impressive in this specific area :man_shrugging:

We’d first have to figure out which part of the code is doing this work. Are you a developer? Can you dive in and debug a bit?

If not, can you get me a “minimal reproducible case”, a “steps to reproduce” this in a clean system? Thanks

I have done some debugging and i can conclude that the “EmailTemplate.php” is not being called for the autoreplies. I was logging in the “EmailTemplateParser.php” file first, but this did not return any logs. After this i started looking into the EmailTemplate.php file and found that the parse_email_template function is not being called when it sends an autoreply.

So this is where the problem may be. Do you have any idea why this may happen?

I dont know if i can provide any coherent steps for a reproducable case. What I do know is that it was upgraded from sugarCRM CE to the latest SuiteCRM version. wich was pretty hard as it is. after that, i only did some adjustments to the layouts in the code (using the layoutdefs in the custom folder) and used nothing but the studio for custom relationships (im not using custom relationships in the email).

To elaborate, i have put a logger in the constructor of the EmailTemplate class, to check if the class was created correctly, and one in the “parse_email_template” function. both logs show up on sending a reply from the emails module, but none show up upon sending an autoreply

Can you check if the autor-replies are going through here?

–> https://github.com/salesagility/SuiteCRM/blob/master/modules/Emails/Email.php#L922

I added an `error_log’ to the top of the email2Send function and it does not seem to be called in both cases (autoreply and email module)

Let’s work from the opposite direction, let’s find a log message that happens during the auto-replies, and figure out the call stack that takes us there.

Check the suitecrm.log, in debug level, and try to figure out a message that appears always (and only) on an auto-reply, and we can look for it in the code.

I have checked the logs on debug level, and I found a couple of peculiar lines that might get me closer to fixing the issue.

the log lines were:

Wed Apr 15 13:30:12 2020 [15529][1][FATAL] *** FOLDERS: addBean() is trying to save to a non-saved or non-existent folder
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] userId [ ]
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] In handleCreateCase
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] retrieveing email
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] Hook called: ::server_round_trip
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] Calling MySQLi::disconnect()
Wed Apr 15 13:30:12 2020 [15529][1][FATAL] Job 962962dd-c880-71a2-f19a-5e970cf3688a (Check Inbound Mailboxes) failed in CRON run
Wed Apr 15 13:30:12 2020 [15529][1][INFO] Resolving job 962962dd-c880-71a2-f19a-5e970cf3688a as failure: Unexpected failure, please check PHP logs and suitecrm.log
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] Hook called: SchedulersJobs::job_failure
Wed Apr 15 13:30:12 2020 [15529][1][DEPRECATED] Formatting correction: SchedulersJobs->failure_count had formatting automatically corrected. This will be removed in the future, please upgrade your external code
Wed Apr 15 13:30:12 2020 [15529][1][DEBUG] Hook called: SchedulersJobs::before_save
Wed Apr 15 13:30:12 2020 [15529][1][INFO] Query:UPDATE job_queue
SET assigned_user_id=‘1’,name=‘Check Inbound Mailboxes’,date_modified=‘2020-04-15 13:30:01’,scheduler_id=‘3f428d44-eaaa-489d-0003-5e8d979faa1e’,execute_time=‘2020-04-15 13:30:00’,status=‘done’,resolution=‘failure’,message=‘Unexpected failure, please check PHP logs and suitecrm.log\n’,target=‘function::pollMonitoredInboxes’,data=NULL,requeue=0,retry_count=NULL,failure_count=1,job_delay=0,client=‘CRON886dfd7961861390dcb39cf095f63f68:15529’,percent_complete=NULL
WHERE job_queue.id = ‘962962dd-c880-71a2-f19a-5e970cf3688a’ AND deleted=0
Wed Apr 15 13:30:12 2020 [15529][1][INFO] Query Execution Time:0.00089812278747559

I have looked into the php error log as the lines said, but nothing shows up, so the job must be failing somewhere, and thus skipping out on the parsing while still sending the email