Etomite Community Forums: [Snippet] emailSender - Etomite Community Forums

Jump to content

Read Me

This forum is posted in automatically when a snippet is added to the library, or updated. Please use the snippet topic to discuss that snippet.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Snippet] emailSender

#1 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,063
  • Joined: 10-August 06
  • Location:Brisbane, Queensland, Australia

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

This post has been edited by Cris D.: 05 February 2009 - 07:31 AM


#2 User is offline   PaulD 

  • Likes Etomite Forums!
  • PipPip
  • Group: Member
  • Posts: 298
  • Joined: 06-February 06
  • Gender:Male
  • Location:Lutterworth, Leicestershire

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 User is offline   Cris D. 

  • Loves Etomite Forums!
  • PipPipPipPip
  • Group: Member
  • Posts: 1,063
  • Joined: 10-August 06
  • Location:Brisbane, Queensland, Australia

Posted 05 February 2009 - 07:32 AM

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

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users