Send An Email from within A Page
Posted: Thu Feb 14, 2008 5:35 pm
Here's a simple example of an advanced topic: Accessing CMSMailer from within your page content.
Here's my code.... for reference:
This code creates a simple form with a single submit button on it. When the button is clicked, the result is returned to the same page, and the smarty logic kicks in.
First the {cmsmailer} udt is invoked which simply assigns the cmsmailer object to smarty for use in our page
Then I call the various cmsmailer methods to send an email.
This example kinds blurs the lines between programming and layout and design, but only a little bit
I'm sure you can find many uses for code like this to send messages from within your page.
Here's the code for the cmsmailer UDT:
Here's my code.... for reference:
Code: Select all
{if isset($smarty.post.submit)}
{cmsmailer} {* udt *}
{$cmsmailer->reset()}
{$cmsmailer->SetSubject('Test Message')}
{$cmsmailer->AddAddress('calguy1000@cmsmadesimple.org')}
{$cmsmailer->SetBody('This is a test message')}
{$cmsmailer->Send()}
Message Sent
{else}
<form name="test" method="post">
<input type="submit" name="submit" value="Send Test Message">
</form>
{/if}
First the {cmsmailer} udt is invoked which simply assigns the cmsmailer object to smarty for use in our page
Then I call the various cmsmailer methods to send an email.
This example kinds blurs the lines between programming and layout and design, but only a little bit

I'm sure you can find many uses for code like this to send messages from within your page.
Here's the code for the cmsmailer UDT:
Code: Select all
global $gCms;
$smarty =& $gCms->GetSmarty();
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$smarty->assign_by_ref('cmsmailer',$cmsmailer);