Jump to content


[Snippet] emailSender


2 replies to this topic

#1 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 08 December 2008 - 01:19 PM

File Name: emailSender
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.


#2 PaulD

    Likes Etomite Forums!

  • Developers
  • PipPip
  • 389 posts
  • Gender:Male

Posted 04 February 2009 - 10:03 PM

Hi Chris - thanks for the snippet.

Just to save anyone else some time that uses this here are a few typos. The snippett itself was perfect, the instructions on the snippett description in the library had the typos.

View PostCris D., on Dec 8 2008, 01:19 PM, said:

$params=array(
'flag'=>$flag, //leave blank or set to false to stop the email from sending.
'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.
THe final line needs a semicolon
'headers'=>$headers);//Optional- MIME, Content type: text/html, etomite charset, and Return Path are sent by default.

The $message field is also missing from the array. Add in anywhere.
i.e. change
$params=array(
'flag'=>$flag, //leave blank or set to false to stop the email from sending.
'subject'=>$subject, //RFC2047 standard (see PHP.net function mail()  for more)
to
$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)

Finally:

View PostCris D., on Dec 8 2008, 01:19 PM, said:

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.
There should be a comma between the two parameters.
$var=$etomite->runSnippet('emailSender', $params);//returns true on success, false on failure and error if phpini mail is not set up.

Again, the snippet itself works perfectly. Thanks Chris. I hope pointing out these minor typos helps someone.

Paul.

#3 Cris D.

    Loves Etomite Forums!

  • Developers
  • PipPipPipPip
  • 1,104 posts
  • Gender:Male

Posted 05 February 2009 - 07:32 AM

Thanks Paul. Instructions above modified to reflect the noted changes :)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users