25/02/2010, 23:00
|
| | Fecha de Ingreso: noviembre-2004 Ubicación: NULL
Mensajes: 655
Antigüedad: 20 años, 2 meses Puntos: 6 | |
Respuesta: Correo Futuro Código PHP: <?php
/*
=====================================================
ExpressionEngine - by pMachine
-----------------------------------------------------
http://www.pmachine.com/
-----------------------------------------------------
Copyright (c) 2003,2004,2005 pMachine, Inc.
=====================================================
THIS IS COPYRIGHTED SOFTWARE
PLEASE READ THE LICENSE AGREEMENT
http://eedocs.pmachine.com/license.html
=====================================================
File: pi.cron_email.php
-----------------------------------------------------
Purpose: Send an email to a person or mailing list
at a scheduled time each day
=====================================================
*/
$plugin_info = array(
'pi_name' => 'Send Email',
'pi_version' => '1.0',
'pi_author' => 'Paul Burdick',
'pi_author_url' => 'http://www.web.com/',
'pi_description' => 'Cron based email sending',
'pi_usage' => Cron_email::usage()
);
class Cron_email {
var $return_data = '';
// ----------------------------------------
// HTML Formatting Buttons
// ----------------------------------------
function Cron_email()
{
global $TMPL, $LOC, $REGX, $PREFS, $DB;
$to = ($TMPL->fetch_param('to') !== FALSE) ? $TMPL->fetch_param('to') : '';
$cc = ($TMPL->fetch_param('cc') !== FALSE) ? $TMPL->fetch_param('cc') : '';
$bcc = ($TMPL->fetch_param('bcc') !== FALSE) ? $TMPL->fetch_param('bcc') : '';
$from = ($TMPL->fetch_param('from') !== FALSE) ? $TMPL->fetch_param('from') : $PREFS->ini('webmaster_email');
$subject = ($TMPL->fetch_param('subject') !== FALSE) ? $TMPL->fetch_param('subject') : '';
$message = $TMPL->tagdata;
if ($to == '' OR $subject == '' OR $message == '') return false;
if ($TMPL->fetch_param('parse_tag') == 'on' && stristr($message, '{'))
{
$top = '';
$bottom = '';
if (preg_match("/".LD.'email_top'.RD."(.*?)".LD.SLASH.'email_top'.RD."/s", $TMPL->tagdata, $matches))
{
$top = $matches['1'];
$TMPL->tagdata = str_replace($matches['0'], '', $TMPL->tagdata);
}
if (preg_match("/".LD.'email_bottom'.RD."(.*?)".LD.SLASH.'email_bottom'.RD."/s", $TMPL->tagdata, $matches))
{
$bottom = $matches['1'];
$TMPL->tagdata = str_replace($matches['0'], '', $TMPL->tagdata);
}
// ----------------------------------------
// Fetch the weblog entry
// ----------------------------------------
if ( ! class_exists('Weblog'))
{
require PATH_MOD.'/weblog/mod.weblog'.EXT;
}
$weblog = new Weblog;
$weblog->fetch_custom_weblog_fields();
$weblog->fetch_custom_member_fields();
$weblog->build_sql_query();
$weblog->query = $DB->query($weblog->sql);
if ($weblog->query->num_rows == 0)
{
return false;
}
if ( ! class_exists('Typography'))
{
require PATH_CORE.'core.typography'.EXT;
}
$weblog->TYPE = new Typography;
$weblog->TYPE->encode_email = false;
$TMPL->tagparams['rdf'] = 'off'; // Turn off RDF code
$weblog->fetch_categories();
$weblog->parse_weblog_entries();
$message = $top.$weblog->return_data.$bottom;
}
$message = $REGX->entities_to_ascii($message);
if ( ! class_exists('EEmail'))
{
require PATH_CORE.'core.email'.EXT;
}
$email = new EEmail;
$email->wordwrap = false;
$email->initialize();
$email->to($to);
$email->cc($cc);
$email->bcc($bcc);
$email->from($from);
$email->subject($subject);
$email->message($message);
$email->Send();
return TRUE;
}
// END
// ----------------------------------------
// Plugin Usage
// ----------------------------------------
// This function describes how the plugin is used.
// Make sure and use output buffering
function usage()
{
ob_start();
?>
Allows you to schedule the sending of an email to the email addresses specified
in the parameters. The tag data (that which is between the opening and closing tag)
will be the contents of the email's message.
As a perk, you can have the tag data parsed exactly as if it were part of
an {exp:weblog:entries} tag. This allows you to, say, schedule the sending of an
email at the beginning of every day containing the most recently posted entries of that day.
=====================
Parameters
=====================
to="" - Recipient(s) of email [required]
from="" - Sender of email [optional, default webmaster of site]
cc="" - CC Recipient(s) of email [required]
bcc="" - BCC Recipient(s) of email [required]
subject="" - Subject line of email [required]
parse_tag="" - If set to 'on' it will parse the tagdata as if it were part of a
{exp:weblog:entries} tag. When set to 'on' the tag will accept all of the usual
parameters for the {exp:weblog:entries} tag as well. [optional]
=====================
Pair Variables
=====================
{email_top}{/email_top} - When parse_tag is set to "on" the content between this variable pair will be removed from
the tagdata (i.e. not parsed) and placed at the top of the sent email. Think email heading and opening statement
{email_bottom}{/email_bottom} - When parse_tag is set to "on" the content between this variable pair will be removed from
the tagdata (i.e. not parsed) and placed at the bottom of the sent email. Think signature.
=====================
EXAMPLES
=====================
{exp:cron plugin="cron_email" day="23" minute="59" to="[email protected]" subject="Daily Email"}
Hello There!
{/exp:cron}
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
// END
}
// END CLASS
?> |