Hiya,
Just wondering if someone can show me the error of my ways on this one?
I have a very simple plugin (code shown below) which when called in a template using this code :
{exp:admin_email redirect="template_group/template"}I was hoping that it would first send the email and then secondly redirect to the redirect=”template_group/template” template that is set in the plugin parameter.
I’m not getting the e-mail sent and not getting the re-direct happening either. If I take out all the email sending part though the plugin does redirect to the other template so I know that bit’s working.
Anyone know why the email sending part wouldn’t be working though?
<?php
/*
=========================================================================
Copyright (c) 2008 Mark Bowen Design
=========================================================================
File: pi.admin_email.php V1.0
-------------------------------------------------------------------------
Purpose: Send admin an email
=========================================================================
CHANGE LOG :
18th September 2009
- Version 1.0
- Creation of initial plugin
=========================================================================
*/
$plugin_info = array(
'pi_name' => 'Admin Email',
'pi_version' => '1.0',
'pi_author' => 'Mark Bowen',
'pi_author_url' => 'http://www.markbowendesign.com/',
'pi_description' => 'Send an email to the admin',
'pi_usage' => Admin_email::usage()
);
class Admin_email
{
var $return_data = "";
function Admin_email()
{
global $TMPL, $DB, $SESS, $FNS;
$tagdata = $TMPL->tagdata;
// Set up a few constants
$member_id = $SESS->userdata['member_id'];
$redirect = $TMPL->fetch_param('redirect');
$recipient = "[email protected]";
$from = "[email protected]";
$email_subject = "Email Subject";
$email_msg = "This is the body content of the email";
if ( ! class_exists('EEmail'))
{
require PATH_CORE.'core.email'.EXT;
}
$email = new EEmail;
$email->wordwrap = true;
$email->mailtype = 'text';
$email->from($from);
$email->to($recipient);
$email->subject($email_subject);
$email->message($REGX->entities_to_ascii($email_msg));
$email->Send();
$redirect = $FNS->create_url($redirect);
$FNS->redirect($redirect);
// $this->return_data .= $tagdata;
}
// ----------------------------------------
// Plugin Usage
// ----------------------------------------
// This function describes how the plugin is used.
// Make sure and use output buffering
function usage()
{
ob_start();
?>
<?php
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
// END
}
/* End of file pi.admin_email.php */
/* Location: system/plugins/pi.admin_email.php */Thanks for any help on this.
Best wishes,
Mark
Any of the moderators possibly want to show me the error of my ways maybe? 😉
Unless I’m being completely blind (probably the case ;- ) ) I’m pretty sure I just copied the email part from the documentation exactly as it was but it just doesn’t seem to want to work. If I however place a standard PHP mail() function in there instead then I get the e-mail so I’m a little confused as to what I’m doing wrong here.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.