Versenden einer Email nach der Validierung
Es ist möglich nach der Validierung eine Email zu versenden.
Hier ein Beispiel wie dieser Versand realisiert werden kann:
<?php
// ========================================================
// UserExit after Validation
// ========================================================
use Squeeze\SqueezeConfig;
use Squeeze\xTools;
function AfterValidation(\Squeeze\xDoc $xDoc, $nextStep, $newStatus){
$logger = Logger::getLogger("main");
$subject = 'Test after Validation';
$to = array('test(at)test.de');
$body = 'Erster Test zum Versenden einer Email mit Anlagen. HTML Emails wären auch möglich sind aber komplexer.';
$attachments = array();
$config = new SqueezeConfig();
$repo = $config->get('repository.root');
$absolutePath = xTools::buildAbsolutePath($repo, $xDoc->repoPath, false);
if ($absolutePath == false){
$msg = "AfterValidation Input Folder (".$repo . $xDoc->repoPath.") does not exist.";
$logger->error($msg);
throw new Exception($msg);
}
$files = $xDoc->getBase64Files($absolutePath, 'Input', array('pdf'));
foreach ($files->getResult() as $file) {
if ($file->filename != '_result.pdf') {
$attachments[] = $absolutePath . 'Input' . DIRECTORY_SEPARATOR . $file->filename;
}
}
$result = xTools::sendEmail($subject, $to, $body, 'text', $attachments);
if($result->isSuccess() === false) {
throw new Exception($result->getMessage());
}
return array('xDoc' => $xDoc, 'nextStep' => $nextStep, 'newStatus' => $newStatus);
}