Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#813544
Hi,

We have been working on implementing some business processes using ProcessMaker. We have been observing an issue regarding attachments in sending email through ProcessMaker.

Here is the issue in detail.

1. We have a timer task in which it sends some emails to business users with some attachment produced by PM. But we have been observing that emails are sent sometimes without attachment but sometimes email contains attachment.

2. To dig down the problem we have checked each step before sending email but we have found that attachment file exists before sending email.

3. In any process flow, email sending with attachment is working perfectly. But for timer task sometimes emails are sent without attachment and sometimes email is sent without attachment.

4. Following is the code block which is executed on trigger of the timer task.
Code: Select all
@%emailCounter++;

try{
	
	$to = 'xxxx@gmail.com';

	$caseId = @@APPLICATION;

	$aAttachments = [];

	@@debugStr = "";

	@@fileQuery = "select `APP_DOC_UID`, `DOC_VERSION` FROM `APP_DOCUMENT` where `APP_UID`='$caseId' order by `DOC_VERSION` desc limit 1";
	$aFiles = executeQuery(@@fileQuery);

	@@debugStr .= ";<br/> File counts = ".count($aFiles);

	foreach ($aFiles as $aFile)
	{
		@@debugStr .= ";<br/> File = ".$aFile['APP_DOC_UID'];

		$oDoc = new AppDocument();
		$aDocInfo = $oDoc->Load($aFile['APP_DOC_UID'], $aFile['DOC_VERSION']);

		@@debugStr .= ";<br/> File Info = ".json_encode($aDocInfo);

		$ext = '.pdf';  //set to '.doc' if sending a DOC file
		$g = new G();
		$pathToFile = PATH_DOCUMENT . $g->getPathFromUID(@@APPLICATION) . PATH_SEP . 'outdocs' .  PATH_SEP . $aFile['APP_DOC_UID'] . '_' . $aDocInfo['DOC_VERSION'] . $ext;
		@@debugStr .= ";<br/> File path = ".$pathToFile;
		$filename = @@selfNamePDF;
		
		$aAttachments = PMFAddAttachmentToArray($aAttachments, $filename, $pathToFile);
		
	}

	@@subjectLine = '[Test - attachment] '.@@title;
	
	PMFSendMessage(@@APPLICATION, 'yyyy@zzz.com', $to , 'pppp@gmail.com','' , @@subjectLine, 'TestEmail.html', array(), $aAttachments);
	
} catch (Exception $e) {
	PMFSendMessage(@@APPLICATION, 'yyyy@zzz.com', $to , 'mmmm@gmail.com','' , 'Exception Occured - '.$e->getMessage(), 'TestEmail.html', array(), $aAttachments);
}


Anybody has any idea or any direction for us? We would be very grateful if we could get any suggestion. With this issue we are very much negative concern using PM. Need your help to get rid of this problem.
#813556
I've never seen this problem before. We need to see the PHP error or SQL query which is causing the problem.
Edit your workflow/engine/config/env.ini file and add the following two lines:
Code: Select all
debug = 1
debug_sql = 1
The next time you see the problem in a email, check the contents of your workflow/public_html/php_errors.log, shared/log/propel.log and shared/log/queriesWithErrors.log files. If you don't want to wait, manually execute the workflow/engine/bin/timereventcron.php file from the command line until you see an email with the problem.

PS: As a workaround, you can include links to files in your email template, instead of adding the files as attachments.
#813600
Hi amosbatto,

Thank you for your response. We really appreciate your help.

Just few things, we would like to share about this problem additionally. This scenario is happening in production server. So, we are unable to debug there. But we have tested with testing server in which there is few loads on server and there is not hard restriction in OS level. It seems that in testing server, it is working but it is not working in production. In production server, the load is high and lots of emails are sending through PM. Another information, email is sent out through SMTP (PHPMailer).

Today we also observed that, it is not only in timer task. It is happening in other process too in production server. We are now in ambiguous situation. Because emails are sent out sometimes without attachment and sometimes with attachment.

However, could you please guide us to look into this matter in a direction, such as, on high load server perspective or OS security perspective or email server perspective or email sending with attachment using PHPMailer etc?
#813604
Are you using the +force option to execute the ProcessMaker cron scripts (located in /workflow/engine/bin/cron*.php)?
If so, then you are probably cutting short the execution of the cron scripts.
I recommend not using +force and executing them less often so they have more time.
Post your cron configuration if you want me to analyze it.

Also, what are the characteristics (processor, RAM, size of harddrive) of your ProcessMaker server and how many concurrent users do you have. Are you running MySQL on a separate server?

A 1xbet clone script is a pre-designed software so[…]

4rabet clone script is enabling entrepreneurs to e[…]

Parimatch clone script is enabling entrepreneurs t[…]

In the world of cryptocurrency, a wallet is an app[…]