Friday, March 19th, 2010 (updated 26 Jan ’12)

Documentation for Send Email v1.4

 

The Send Email plugin lets you send an email from within an ExpressionEngine template without the user submitting a form.

Compatibility

Compatible with both EE v1.x and v2.x.

Installation

EE v1.x

Place the pi.send_email.php file in the /plugins directory.

EE v2.x

Create in the /third_party directory a directory /send_email, then place the pi.send_email.php in there.

Required Parameters

to

This is the only required parameter, the email address that the email will go to.

Optional Parameters

from_email

The email address that will appear in the email’s From area. If using, also requires the from_name parameter.

from_name

The name address that will appear in the email’s From area. If using, also requires the from_email parameter.

subject

The email’s subject. If left empty, the default is “Email from [site_name]”.

mailtype

Either “html” or “plain”. Default is “plain”. Currently working in EE v2.x only.

parse

This parameter is available to all EE plugins. When set with a value of “inward” it allows the plugin to contain other plugins.

Variables

username, screen_name, member_id, email, ip_address

Example

{exp:send_email 
    from_name
="Joe Kissel" 
    
from_email="joe@kisselmail.org" 
    
to="mail@wackysillyhairpieces.net" 
    
subject="Hairpiece for Pico"
}
Dear Wacky Silly Hairpieces
,

Can you do something about {screen_name}s hairThough he does got to get back to work.

Thank you,

Joe Kissel
{
/exp:send_email} 

Changelog

v1.4 (2012 Jan 26)

  • Replaced code with contribution from Tiffany in comments
  • Added username, screen_name, member_id, email, ip_address parameters

v1.2 (2011 May 3)

  • Forced substitution of “&+47;” to “/” in email body

v1.1 (2010 Mar 19)

  • Added mailtype parameter

Roadmap

  • add support for variables within emails

Thu 15 Apr ’10
1:21pm

Sophia Browne

Does this plugin allow dynamic variables?  I am trying to use {site_name} and {webmaster_email} and they are not being processed.

Thu 15 Apr ’10
2:54pm

Adam Khan

Sophia, try parse=“inward”. If that doesn’t work, I’ll have to work on it to get variables working.

Thu 15 Apr ’10
9:14pm

Sophia Browne

Hi, I tried the parse=inward and that didn’t work either.

Fri 16 Apr ’10
8:30pm

Adam Khan

Sophia, thanks for trying. I’ve added that to the plugin’s roadmap. Can’t say with confidence when exactly I’ll get to it though.

Fri 16 Apr ’10
11:14pm

Sophia Browne

Ok, that’s no problem.  I will just workaround it.

Thanks anyways.

Tue 20 Apr ’10
10:27pm

Kurt

I’m very interested in this. I’ve been asked to create a sort of tell-a-friend/e-card that self submits after a freeform is submitted. This might be a great way to make that happen.

Tue 4 May ’10
5:45pm

Nick Benson

I’m getting the following error on my EE 2 site, any thoughts?

————————-

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant PATH_CORE - assumed ‘PATH_CORE’

Filename: send_email/pi.send_email.php

Line Number: 74

Sun 11 Jul ’10
1:56am

jimboJ

Any news following on from Nick Benson’s comment above? Having the same issue…

Tue 10 Aug ’10
8:50pm

Kyle Batson

I have a request that allows using conditionals inside the message. I’m populating the message field with some custom fields, and if that custom field is not present, I don’t want it to show up. Something simple like {if custom_field}Content here{/if}

Also, might you know why having ‘http://’ in the message field outputs as encoded HTML character entities instead? Is there a way this can be switched from within the plugin?

Thanks.

Wed 25 Aug ’10
6:08am

Adam Khan

Sorry for not responding, people, I’ve been a bit swamped and haven’t had time to address issues on the free plugins.

Nick and JimboJ, I haven’t yet figured out why the PHP notice is happening, sorry!

Kyle, the encoding is happening within EE’s built-in functions that the plugin’s calling—I’ll have to look further to see how to disable that.

Wed 29 Sep ’10
2:42pm

Sophia Browne

Hi,

I added to the send email plugin since I had the same HTML character entities problem.
I added a function from the Regular expressions class to the -> $E->message($REGX->unhtmlentities($message));  Don’t forget to call the class -> global $REGX; // EEv1 syntax.

The unhtmlentities function takes a string and returns with all entities turned into their characters. http://expressionengine.com/legacy_docs/development/reference/regex.html

In a bit of a hurry, so I have to keep this short, hope this helps!

Mon 10 Jan ’11
12:38pm

Adam Khan

Sophie, it’s months later, my apologies for leaving you in the lurch there, presume you got it fixed!

Mon 10 Jan ’11
5:13pm

Sophia Pitt-Browne

Yes Adam, I did!

Thu 17 Mar ’11
6:51am

Stuart

Re: Use of undefined constant PATH_CORE

Looking at the file and the structure of 1.6 V 2.0.1 that the file it’s referencing “core.email” no longer exists in 2.1.X

No idea how to amend or what to amend to :(

Fri 22 Apr ’11
1:41pm

James

I’m getting the same PHP error as Nick, did anyone ever find a way round it?

Tue 24 May ’11
3:11pm

Jim

Any idea when yo might add the functionality for variables?

Wed 22 Jun ’11
2:44pm

Ryan

Hey James, I am also getting the same PHP error as Nick. I have tried everything that I’m aware of, but nothing is working. I’ll just have to be patient, kick my shoes off, and try working around my issue. I seem to get flustered when I can’t get anywhere. I’ll let everyone know if I come up with something.

Tue 2 Aug ’11
3:34pm

Tiffany

I got this to work on EE 2.1.3 by replacing the send email code with this:

        // Send email
        $this->EE->load->library(‘email’);
        $this->EE->email->initialize();
        if ($from_email && $from_name)
        {
          $this->EE->email->from($from_email, $from_name);
        }
        else
        {
          $this->EE->email->from($PREFS->ini(‘webmaster_email’), $PREFS->ini(‘webmaster_name’));
        }
        $this->EE->email->to($to);
        if ($subject)
        {
          $this->EE->email->subject($subject);
        }
        else
        {
          $this->EE->email->subject( “Email from ” . $PREFS->ini(‘site_name’) );
        }
        $this->EE->email->message($message);
        $this->EE->email->Send();

Mon 23 Jan ’12
10:43pm

Adam Khan

Tiffany, a very belated thanks for fixing the plugin. Working for me on EE2. Not sure now though on EE1, will have to check.

Post a comment

Name:

Email:

Location:

URL:

Your comment:

Remember my personal information
Notify me of follow-up comments?

Please enter the word you see in the image below:

How do you spell "doggie"? (6 character(s) required)