File Submitter: Cris D.
File Submitted: 8 Dec 2008
File Category: Feedback / E-Mail Forms
Snippet: emailSender
Author: Cris D
Date: 2008-12-08
Use: This is a generic snippet that allows you to easily add email capabilities to any other snippet, form or code.
Examples of implementation:
Using the runSnippet() API...
1) Collect the snippet parameters to pass to it.
$params=array( 'flag'=>$flag, //leave blank or set to false to stop the email from sending. 'message'=>'Here is the message in the email', 'subject'=>$subject, //RFC2047 standard (see PHP.net function mail() for more) 'to'=>$to, //you guessed it, who to send the email- RFC2822 standard 'sender'=>$sender, //Who will be the sender. Leave blank to get the etomite site config email. 'headers'=>$headers);//Optional- MIME, Content type: text/html, etomite charset, and Return Path are sent by default.2) call the snippet into action using the runSnippet API
$var=$etomite->runSnippet('emailSender', $params);//returns true on success, false on failure and error if phpini mail is not set up.
3) Do something with the value returned from the snippet (true || false)example:
if($var) return "Email successfully sent!";
Using a snippet call to set some variables:
[!emailSender?subject=MyPage!&to=someone@mysite.com!]
Note: When using any email scripts like this, make sure that they are protected from spammers by using a log-in script, captcha or other security code to protect it.
This was originally written to support the reportThisPage snippet.
Click here to download this file
Edited by Cris D., 05 February 2009 - 07:31 AM.












