本文整理匯總了PHP中ilMail::saveAttachments方法的典型用法代碼示例。如果您正苦於以下問題:PHP ilMail::saveAttachments方法的具體用法?PHP ilMail::saveAttachments怎麽用?PHP ilMail::saveAttachments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ilMail
的用法示例。
在下文中一共展示了ilMail::saveAttachments方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: distributeMails
/**
* mail via soap
* @param object $sid
* @param object $a_mail_xml
* @return
*/
public function distributeMails($sid, $a_mail_xml)
{
$this->initAuth($sid);
$this->initIlias();
if (!$this->__checkSession($sid)) {
return $this->__raiseError($this->__getMessage(), $this->__getMessageCode());
}
include_once 'Services/Mail/classes/class.ilMail.php';
include_once 'webservice/soap/classes/class.ilSoapMailXmlParser.php';
$parser = new ilSoapMailXmlParser($a_mail_xml);
try {
// Check if wellformed
libxml_use_internal_errors(true);
$ok = simplexml_load_string($a_mail_xml);
if (!$ok) {
foreach (libxml_get_errors() as $err) {
$error .= $err->message . ' ';
}
return $this->__raiseError($error, 'CLIENT');
}
$parser->start();
} catch (InvalidArgumentException $e) {
$GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
return $this->__raiseError($e->getMessage(), 'CLIENT');
} catch (ilSaxParserException $e) {
$GLOBALS['ilLog']->write(__METHOD__ . ' ' . $e->getMessage());
return $this->__raiseError($e->getMessage(), 'CLIENT');
}
$mails = $parser->getMails();
global $ilUser;
foreach ($mails as $mail) {
// Prepare attachments
include_once './Services/Mail/classes/class.ilFileDataMail.php';
$file = new ilFileDataMail($ilUser->getId());
foreach ((array) $mail['attachments'] as $attachment) {
// TODO: Error handling
$file->storeAsAttachment($attachment['name'], $attachment['content']);
$attachments[] = ilUtil::_sanitizeFilemame($attachment['name']);
}
$mail_obj = new ilMail($ilUser->getId());
$mail_obj->setSaveInSentbox(true);
$mail_obj->saveAttachments((array) $attachments);
$mail_obj->sendMail(implode(',', (array) $mail['to']), implode(',', (array) $mail['cc']), implode(',', (array) $mail['bcc']), $mail['subject'], implode("\n", $mail['body']), (array) $attachments, array($mail['type']), (bool) $mail['usePlaceholders']);
// Finally unlink attachments
foreach ((array) $attachments as $att) {
$file->unlinkFile($att);
}
$mail_obj->savePostData($ilUser->getId(), array(), '', '', '', '', '', '', '', '');
}
return true;
}