Sending an email from within a page

General project discussion. NOT for help questions.
Post Reply
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Sending an email from within a page

Post by jmcgin51 »

Sorry in advance if this is not the right place to post this, but since it relates to CMSMailer, I thought it belonged with questions about the core.

See Calguy's post about sending an email from within a page: http://forum.cmsmadesimple.org/index.ph ... 525.0.html

The code doesn't work for me.  Running CMSMS 1.2.4 with CMSMailer 1.73.12.

I paste the code from Calguy's first post into my page, and create my UDT with the UDT code specified in his post, but this is what I get when I view the page:

string(138) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag: $cmsmailer->reset() (Smarty_Compiler.class.php, line 446)" string(117) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)" string(157) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag: $cmsmailer->SetSubject('Test Message') (Smarty_Compiler.class.php, line 446)" string(117) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)" string(173) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag: $cmsmailer->AddAddress('calguy1000@cmsmadesimple.org') (Smarty_Compiler.class.php, line 446)" string(117) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)" string(164) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag: $cmsmailer->SetBody('This is a test message') (Smarty_Compiler.class.php, line 446)" string(117) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)" string(137) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag: $cmsmailer->Send() (Smarty_Compiler.class.php, line 446)" string(117) "Smarty error: [in content:content_en line 1]: syntax error: unrecognized tag '' (Smarty_Compiler.class.php, line 590)"

What could be causing this?  Is it an issue with CMSMailer, or the way I'm implementing the code, or what?

Please move this post if it belongs somewhere else.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Sending an email from within a page

Post by Nullig »

Well, firstly, I don't think you should be sending emails to calguy's account in your UDT.

Secondly, can you post your {cmsmailer} UDT code, so we can see if it's correct.

Thirdly, have you configured/tested CMSMailer, to see if it works?

Nullig
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Sending an email from within a page

Post by jmcgin51 »

Thanks Nullig.  Yes, obviously I will change the email address, subject, body, etc.  I just copied the code from Calguy's post into my page to make sure it displayed the form.

Here is the {cmsmailer} UDT.  Again, it was copied and pasted directly from Calguy's post.  I don't see anything I need to customize.  Right?

--
global $gCms;

$smarty =& $gCms->GetSmarty();
$cmsmailer =& $gCms->modules['CMSMailer']['object'];

$smarty->assign_by_ref('cmsmailer',$cmsmailer);
--

Yes, CMSMailer is configured and works fine for SelfReg, etc.
User avatar
Nullig
Power Poster
Power Poster
Posts: 2380
Joined: Fri Feb 02, 2007 4:31 pm

Re: Sending an email from within a page

Post by Nullig »

And what is the code you have in your page/template that calls the UDT?

Nullig
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Sending an email from within a page

Post by jmcgin51 »

Sorry - that would probably be helpful ;-)

--
{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}



{/if}
--

Again, copied directly from the forum post.
jmcgin51
Power Poster
Power Poster
Posts: 1899
Joined: Mon Jun 12, 2006 9:02 pm

Re: Sending an email from within a page

Post by jmcgin51 »

Any ideas, Nullig or Calguy?
Post Reply

Return to “General Discussion”