} $mail->MsgHTML($vBody); /* // add attachments if ($attach != null) { foreach ($attach as $a) { $mail->AddAttachment($a['path'], $a['name']); } }*/ //$answer = (!$mail->send()) ? $mail->ErrorInfo : true; SetTaskActivity($vTaskName, true); if ($mail->send()) { $sql = "insert into Emails_Sent(RecordGUID, CreateDate, SentDate, FromEmail, FromName, ToEmail, ToName, CopyToEmail, BlindCopyToEmail, Subject, Body) " . "values('" . $rec['RecordGUID'] . "', '" . $rec['CreateDate'] . "', '" . GetLocalDateTimeAsSQLStr() . "', '" . $rec['FromEmail'] . "', '" . $rec['FromName'] . "', '" . $rec['ToEmail'] . "', '" . $rec['ToName'] . "', '" . $rec['CopyToEmail'] . "', '" . $rec['BlindCopyToEmail'] . "', '" . $rec['Subject'] . "', '" . base64_encode($vBody) . "');"; GetMainConnection()->exec($sql); $sql = "delete from Emails_ToSend where RecordGUID = '" . $rec['RecordGUID'] . "';"; GetMainConnection()->exec($sql); } else { $vContinueProcessing = false; $sql = "update Emails_ToSend set Error = '" . ClearSQLStr($mail->ErrorInfo) . "' where RecordGUID = '" . $rec['RecordGUID'] . "';"; GetMainConnection()->exec($sql); } $mail->ClearAddresses(); $mail->ClearAttachments(); //CountAttempts } usleep(50); // in msec } } catch (Exception $exc) { //echo $exc->getTraceAsString(); if (!empty($vProcessingGUID)) {
function Emails_AddNotify($ADocumentType, $ADocumentID, $ASubject, $ABody, $AOwnerEmail) { $sql = "insert into Emails_Notify(RecordGUID, DocumentType, DocumentID, CreateDate, Subject, Body, OwnerEmail) " . "values(UUID(), {$ADocumentType}, {$ADocumentID}, '" . GetLocalDateTimeAsSQLStr() . "', '" . mb_strimwidth(ClearSQLStr($ASubject), 0, 252, '...') . "', '" . base64_encode($ABody) . "', lower('{$AOwnerEmail}'));"; GetMainConnection()->exec($sql); CURL_SpeedUp_SendEmail(); }