本文整理汇总了PHP中TikiMail::addAttachment方法的典型用法代码示例。如果您正苦于以下问题:PHP TikiMail::addAttachment方法的具体用法?PHP TikiMail::addAttachment怎么用?PHP TikiMail::addAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TikiMail
的用法示例。
在下文中一共展示了TikiMail::addAttachment方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: TikiMail
$smarty->assign('attaching', 'n');
if (isset($_REQUEST["send"])) {
$mail = new TikiMail($user);
$email = $userlib->get_user_email($user);
$mail->setFrom($email);
if (!empty($_REQUEST["cc"])) {
$mail->setCc($_REQUEST["cc"]);
}
if (!empty($_REQUEST["bcc"])) {
$mail->setBcc($_REQUEST["bcc"]);
}
$mail->setSubject($_REQUEST["subject"]);
if ($_REQUEST["attach1"]) {
check_ticket('webmail');
$a1 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach1file"]);
$mail->addAttachment($a1, $_REQUEST["attach1"], $_REQUEST["attach1type"]);
@unlink('temp/mail_attachs/' . $_REQUEST["attach1file"]);
}
if ($_REQUEST["attach2"]) {
check_ticket('webmail');
$a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach2file"]);
$mail->addAttachment($a2, $_REQUEST["attach2"], $_REQUEST["attach2type"]);
@unlink('temp/mail_attachs/' . $_REQUEST["attach2file"]);
}
if ($_REQUEST["attach3"]) {
check_ticket('webmail');
$a3 = $mail->getFile('temp/mail_attachs/' . $_REQUEST["attach3file"]);
$mail->addAttachment($a3, $_REQUEST["attach3"], $_REQUEST["attach3type"]);
@unlink('temp/mail_attachs/' . $_REQUEST["attach3file"]);
}
$mail->setSMTPParams($current["smtp"], $current["smtpPort"], '', $current["useAuth"], $current["username"], $current["pass"]);
示例2: sendForumEmailNotification
/** \brief send the email notifications dealing with the forum changes to
* \brief outbound address + admin notification addresses / forum admin email + watching users addresses
* \param $event = 'forum_post_topic' or 'forum_post_thread'
* \param $object = forumId watch if forum_post_topic or topicId watch if forum_post_thread
* \param $threadId = topicId if forum_post_thread
* \param $title of the message
* \param $topicName name of the parent topic
*/
function sendForumEmailNotification($event, $object, $forum_info, $title, $data, $author, $topicName, $messageId = '', $inReplyTo = '', $threadId, $parentId = '')
{
global $tikilib, $feature_user_watches, $smarty, $userlib, $sender_email;
// Per-forum From address overrides global default.
if ($forum_info['outbound_from']) {
$my_sender = '"' . "{$author}" . '" <' . $forum_info['outbound_from'] . '>';
} else {
$my_sender = $sender_email;
}
//outbound email -> will be sent in utf8 - from sender_email
if ($forum_info['outbound_address']) {
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$mail->setSubject($title);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix() . dirname($foo["path"]);
$reply_link = "\n\n----\n\nReply Link: <" . $machine . "tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_reply_threadId={$object}&comments_parentId={$threadId}&post_reply=1#form>\n";
if (array_key_exists('outbound_mails_reply_link', $forum_info) && $forum_info['outbound_mails_reply_link']) {
$mail->setText($title . "\n" . $data . $reply_link);
} else {
$mail->setText($title . "\n" . $data);
}
$mail->setHeader("Reply-To", $my_sender);
$mail->setHeader("From", $my_sender);
$mail->setSubject($topicName);
if ($inReplyTo) {
$mail->setHeader("In-Reply-To", "<" . $inReplyTo . ">");
}
global $commentslib;
$attachments = $commentslib->get_thread_attachments($object, 0);
if (count($attachments) > 0) {
foreach ($attachments as $att) {
$att_data = $commentslib->get_thread_attachment($att['attId']);
$file = $mail->getFile($att_data['dir'] . $att_data['path']);
$mail->addAttachment($file, $att_data['filename'], $att_data['filetype']);
}
}
$mail->buildMessage();
// Message-ID is set below buildMessage because otherwise lib/webmail/htmlMimeMail.php will over-write it.
$mail->setHeader("Message-ID", "<" . $messageId . ">");
$mail->send(array($forum_info['outbound_address']));
}
$nots = array();
$defaultLanguage = $tikilib->get_preference("language", "en");
// Users watching this forum or this post
if ($feature_user_watches == 'y') {
$nots = $tikilib->get_event_watches($event, $object);
for ($i = count($nots) - 1; $i >= 0; --$i) {
$nots[$i]['language'] = $tikilib->get_user_preference($nots[$i]['user'], "language", $defaultLanguage);
}
}
// Special forward address
//TODO: merge or use the admin notification feature
if ($forum_info["useMail"] == 'y') {
$not['email'] = $forum_info['mail'];
if ($not['user'] = $userlib->get_user_by_email($forum_info['mail'])) {
$not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage);
} else {
$not['language'] = $defaultLanguage;
}
$nots[] = $not;
}
if (count($nots)) {
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$smarty->assign('mail_forum', $forum_info["name"]);
$smarty->assign('mail_title', $title);
$smarty->assign('mail_date', date("U"));
$smarty->assign('mail_message', $data);
$smarty->assign('mail_author', $author);
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix() . dirname($foo["path"]);
$machine = preg_replace("!/\$!", "", $machine);
// just incase
$smarty->assign('mail_machine', $machine);
$smarty->assign('forumId', $forum_info["forumId"]);
if ($event == "forum_post_topic") {
$smarty->assign('new_topic', 'y');
$smarty->assign('topicId', $threadId);
} else {
$smarty->assign('topicId', $object);
}
$smarty->assign('mail_topic', $topicName);
foreach ($nots as $not) {
$mail->setUser($not['user']);
$mail_data = $smarty->fetchLang($not['language'], "mail/notification_subject.tpl");
$mail->setSubject($mail_data);
$mail_data = $smarty->fetchLang($not['language'], "mail/forum_post_notification.tpl");
$mail->setText($mail_data);
$mail->buildMessage();
$mail->send(array($not['email']));
}
//.........这里部分代码省略.........
示例3: empty
$smarty->assign('sent', 'n');
$smarty->assign('attaching', 'n');
if (isset($_REQUEST['send'])) {
$email = empty($current['fromEmail']) ? $userlib->get_user_email($user) : $current['fromEmail'];
$mail = new TikiMail($user, $email);
if (!empty($_REQUEST['cc'])) {
$mail->setCc($_REQUEST['cc']);
}
if (!empty($_REQUEST['bcc'])) {
$mail->setBcc($_REQUEST['bcc']);
}
$mail->setSubject($_REQUEST['subject']);
if ($_REQUEST['attach1']) {
check_ticket('webmail');
$a1 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach1file']);
$mail->addAttachment($a1, $_REQUEST['attach1'], $_REQUEST['attach1type']);
@unlink('temp/mail_attachs/' . $_REQUEST['attach1file']);
}
if ($_REQUEST['attach2']) {
check_ticket('webmail');
$a2 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach2file']);
$mail->addAttachment($a2, $_REQUEST['attach2'], $_REQUEST['attach2type']);
@unlink('temp/mail_attachs/' . $_REQUEST['attach2file']);
}
if ($_REQUEST['attach3']) {
check_ticket('webmail');
$a3 = file_get_contents('temp/mail_attachs/' . $_REQUEST['attach3file']);
$mail->addAttachment($a3, $_REQUEST['attach3'], $_REQUEST['attach3type']);
@unlink('temp/mail_attachs/' . $_REQUEST['attach3file']);
}
if ($_REQUEST['fattId']) {
示例4: deleteOldFiles
function deleteOldFiles()
{
global $prefs, $smarty;
include_once 'lib/webmail/tikimaillib.php';
$query = 'select * from `tiki_files` where `deleteAfter` < ' . $this->now . ' - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
$files = $this->fetchAll($query, array());
foreach ($files as $fileInfo) {
if (empty($galInfo) || $galInfo['galleryId'] != $fileInfo['galleryId']) {
$galInfo = $this->get_file_gallery_info($fileInfo['galleryId']);
if (!empty($prefs['fgal_delete_after_email'])) {
$smarty->assign_by_ref('galInfo', $galInfo);
}
}
if (!empty($prefs['fgal_delete_after_email'])) {
$savedir = $this->get_gallery_save_dir($galInfo['galleryId'], $galInfo);
$fileInfo['data'] = file_get_contents($savedir . $fileInfo['path']);
$smarty->assign_by_ref('fileInfo', $fileInfo);
$mail = new TikiMail();
$mail->setSubject(tra('Old File deleted:', $prefs['site_language']) . ' ' . $fileInfo['filename']);
$mail->setText($smarty->fetchLang($prefs['site_language'], 'mail/fgal_old_file_deleted.tpl'));
$mail->addAttachment($fileInfo['data'], $fileInfo['filename'], $fileInfo['filetype']);
$to = preg_split('/ *, */', $prefs['fgal_delete_after_email']);
$mail->send($to);
}
$this->remove_file($fileInfo, $galInfo, false);
}
}
示例5: deleteOldFiles
function deleteOldFiles()
{
global $prefs;
$smarty = TikiLib::lib('smarty');
include_once 'lib/webmail/tikimaillib.php';
$query = 'select * from `tiki_files` where `deleteAfter` < ? - `lastModif` and `deleteAfter` is not NULL and `deleteAfter` != \'\' order by galleryId asc';
$files = $this->fetchAll($query, array($this->now));
foreach ($files as $fileInfo) {
$definition = $this->getGalleryDefinition($fileInfo['galleryId']);
$galInfo = $definition->getInfo();
if (!empty($prefs['fgal_delete_after_email'])) {
$wrapper = $definition->getFileWrapper($fileInfo['data'], $fileInfo['path']);
$fileInfo['data'] = $wrapper->getContent();
$smarty->assign('fileInfo', $fileInfo);
$smarty->assign('galInfo', $galInfo);
$mail = new TikiMail();
$mail->setSubject(tra('Old File deleted:', $prefs['site_language']) . ' ' . $fileInfo['filename']);
$mail->setText($smarty->fetchLang($prefs['site_language'], 'mail/fgal_old_file_deleted.tpl'));
$mail->addAttachment($fileInfo['data'], $fileInfo['filename'], $fileInfo['filetype']);
$to = preg_split('/ *, */', $prefs['fgal_delete_after_email']);
$mail->send($to);
}
$this->remove_file($fileInfo, $galInfo, false);
}
}
示例6: elseif
if ($tikilib->page_exists($page)) {
// Check permissions
$chkUser = $aux["sender"]["user"];
if ($acc["anonymous"] == 'n' && !$userlib->user_has_permission($chkUser, 'tiki_p_admin')) {
if (!$wikilib->user_has_perm_on_object($chkUser, $page, 'wiki page', 'tiki_p_view')) {
$errorMsg = $chkUser . " cannot view the page: " . $page . "<br />";
$logslib->add_log('mailin', mailin_preplog($errorMsg), $logUser);
$content .= $errorMsg;
$processEmail = false;
}
}
if ($processEmail) {
$mail->setSubject($page);
$info = $tikilib->get_page_info($page);
$data = $tikilib->parse_data($info["data"]);
$mail->addAttachment($info['data'], 'source.txt', 'plain/txt');
$mail->setHTML($data, strip_tags($data));
}
} else {
$l = $prefs['language'];
$mail_data = $smarty->fetchLang($l, "mail/mailin_reply_subject.tpl");
$mail->setSubject($mail_data . $page);
}
if ($processEmail) {
$res = $mail->send(array($email_from), 'mail');
$content .= "Response sent<br />";
$hasError = false;
}
} elseif ($acc['type'] == 'wiki-put' || $acc['type'] == 'wiki' && $method == "PUT") {
//////////////
// wiki-put, wiki PUT: Send a wiki page. User emails page to System
示例7: sendForumEmailNotification
/** \brief send the email notifications dealing with the forum changes to
* \brief outbound address + admin notification addresses / forum admin email + watching users addresses
* \param $event = 'forum_post_topic' or 'forum_post_thread'
* \param $object = forumId watch if forum_post_topic or topicId watch if forum_post_thread
* \param $threadId = topicId if forum_post_thread
* \param $title of the message
* \param $topicName name of the parent topic
*/
function sendForumEmailNotification($event, $object, $forum_info, $title, $data, $author, $topicName, $messageId = '', $inReplyTo = '', $threadId, $parentId, $contributions = '', $postId = '')
{
global $tikilib, $prefs, $smarty, $userlib;
// Per-forum From address overrides global default.
if ($forum_info['outbound_from']) {
$author = $userlib->clean_user($author);
$my_sender = '"' . "{$author}" . '" <' . $forum_info['outbound_from'] . '>';
} else {
$my_sender = $prefs['sender_email'];
}
//outbound email -> will be sent in utf8 - from sender_email
if ($forum_info['outbound_address']) {
include_once 'lib/webmail/tikimaillib.php';
$mail = new TikiMail();
$mail->setSubject($title);
if (!empty($forum_info['outbound_mails_reply_link']) && $forum_info['outbound_mails_reply_link'] == 'y') {
$foo = parse_url($_SERVER["REQUEST_URI"]);
$machine = $tikilib->httpPrefix(true) . dirname($foo["path"]);
if ($event == 'forum_post_topic') {
$reply_link = "{$machine}/tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_parentId={$threadId}#form";
} else {
$reply_link = "{$machine}/tiki-view_forum_thread.php?forumId=" . $forum_info['forumId'] . "&comments_reply_threadId={$object}&comments_parentId={$threadId}&post_reply=1#form";
}
} else {
$reply_link = '';
}
$smarty->assign('title', $title);
$smarty->assign('data', $data);
$smarty->assign('reply_link', $reply_link);
$smarty->assign('author', $author);
$mail_data = $smarty->fetch("mail/forum_outbound.tpl");
$mail->setText($mail_data);
$mail->setReplyTo($my_sender);
$mail->setFrom($my_sender);
$mail->setSubject($topicName);
if ($inReplyTo) {
$mail->setHeader("In-Reply-To", "<" . $inReplyTo . ">");
}
global $commentslib;
$attachments = $commentslib->get_thread_attachments($event == 'forum_post_topic' ? $threadId : $object, 0);
if (count($attachments) > 0) {
foreach ($attachments as $att) {
$att_data = $commentslib->get_thread_attachment($att['attId']);
if ($att_data['dir'] . $att_data['path'] == "") {
// no path to file on disk
$file = $att_data['data'];
// read file from database
} else {
$file = $mail->getFile($att_data['dir'] . $att_data['path']);
// read file from disk
}
$mail->addAttachment($file, $att_data['filename'], $att_data['filetype']);
}
}
// Message-ID is set below buildMessage because otherwise lib/webmail/htmlMimeMail.php will over-write it.
$mail->setHeader("Message-ID", "<" . $messageId . ">");
$mail->send(array($forum_info['outbound_address']));
}
$nots = array();
$defaultLanguage = $prefs['site_language'];
// Users watching this forum or this post
if ($prefs['feature_user_watches'] == 'y' || $prefs['feature_group_watches'] == 'y') {
$nots_raw = $tikilib->get_event_watches($event, $event == 'forum_post_topic' ? $forum_info['forumId'] : $threadId, $forum_info);
$nots = array();
$users = array();
foreach ($nots_raw as $n) {
if ($n['user'] != $author && !in_array($n['user'], $users)) {
// make sure user receive only one notification even if he is monitoring both the topic and thread
$n['language'] = $tikilib->get_user_preference($n['user'], "language", $defaultLanguage);
$nots[] = $n;
$users[] = $n['user'];
}
}
}
// Special forward address
//TODO: merge or use the admin notification feature
if ($forum_info["useMail"] == 'y') {
$not['email'] = $forum_info['mail'];
if ($not['user'] = $userlib->get_user_by_email($forum_info['mail'])) {
$not['language'] = $tikilib->get_user_preference($not['user'], "language", $defaultLanguage);
} else {
$not['language'] = $defaultLanguage;
}
$nots[] = $not;
}
if ($prefs['feature_user_watches'] == 'y' && $prefs['feature_daily_report_watches'] == 'y') {
$reportsManager = Reports_Factory::build('Reports_Manager');
$reportsManager->addToCache($nots, array("event" => $event, "forumId" => $forum_info['forumId'], "forumName" => $forum_info['name'], "topicId" => $threadId, "threadId" => $postId, "threadName" => $topicName, "user" => $author));
}
if (count($nots)) {
include_once 'lib/webmail/tikimaillib.php';
$smarty->assign('mail_forum', $forum_info["name"]);
//.........这里部分代码省略.........
示例8: empty
$email = empty($current['fromEmail']) ? $userlib->get_user_email($user) : $current['fromEmail'];
$mail = new TikiMail($user, $email);
if (!empty($_REQUEST['cc'])) {
$mail->setCc($_REQUEST['cc']);
}
if (!empty($_REQUEST['bcc'])) {
$mail->setBcc($_REQUEST['bcc']);
}
$mail->setSubject($_REQUEST['subject']);
if ($_REQUEST['attach1']) {
check_ticket('webmail');
$a1 = $mail->getFile('temp/mail_attachs/' . $_REQUEST['attach1file']);
$mail->addAttachment($a1, $_REQUEST['attach1'], $_REQUEST['attach1type']);
@unlink('temp/mail_attachs/' . $_REQUEST['attach1file']);
}
if ($_REQUEST['attach2']) {
check_ticket('webmail');
$a2 = $mail->getFile('temp/mail_attachs/' . $_REQUEST['attach2file']);
$mail->addAttachment($a2, $_REQUEST['attach2'], $_REQUEST['attach2type']);
@unlink('temp/mail_attachs/' . $_REQUEST['attach2file']);
}
if ($_REQUEST['attach3']) {
check_ticket('webmail');
$a3 = $mail->getFile('temp/mail_attachs/' . $_REQUEST['attach3file']);