Forums / Setup & design / Send 2 emails from a single collector, is it possible?

Send 2 emails from a single collector, is it possible?

Author Message

Daniele Conci

Monday 27 December 2010 7:23:14 am

Hi everyone

actually i'm using a form, which uses an override on the template /extension/ezwebin/design/ezwebin/templates/content/ collectedinfomail/form.tpl to send an email containing the collected information.

{*?template charset=utf-8?*}
{set-block scope=root variable=subject}

{"Collected information from%1"|i18n("design/ezwebin/collectedinfomail/form" ,,array($collection.object.name|wash))}{/set-block}

{set-block scope=root variable=email_receiver} [email protected] {/set-block}
{" THE INFORMATION COLLECTED ARE : "|i18n("design/ezwebin/collectedinfomail/form")}:{foreach $collection.attributes as $attribute}{$attribute.contentclass_attribute_name|wash}:{attribute_result_gui view=info attribute=$attribute}{/foreach}

What i like to add now is an other email destinatary. I tried to modify the following line like this:

{set-block scope=root variable=email_receiver} [email protected], [email protected] {/set-block}

but i verified that's not the right way!

Anyone has a suggestion, or know how to do this?

thanks and best regards,

Daniele

Edi Modrić

Monday 27 December 2010 8:06:53 am

Hi Daniele,

you can use email_cc_receivers and email_bcc_receivers persistent variables for that purposes.

Try this example (works well for me):

{set-block scope=root variable=email_receiver}[email protected]{/set-block} 

{def $email_cc_receivers=array('[email protected]', '[email protected]') scope=root}

eZ Publish certified developer

http://ez.no/certification/verify/350658

Thiago Campos Viana

Wednesday 29 December 2010 3:33:21 pm

"

Hi Daniele,

you can use email_cc_receivers and email_bcc_receivers persistent variables for that purposes.

Try this example (works well for me):

{set-block scope=root variable=email_receiver}[email protected]{/set-block} 

{def $email_cc_receivers=array('[email protected]', '[email protected]') scope=root}
"

wow! If I learnt it before I should never wrote some extensions just for this purpose, maybe the default feedback form ( from ez web interface or ez flow ) could support it out of box.

eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924

Twitter: http://twitter.com/tcv_br

Daniele Conci

Thursday 30 December 2010 12:39:32 am

"
{set-block scope=root variable=email_receiver}[email protected]{/set-block} 

{def $email_cc_receivers=array('[email protected]', '[email protected]') scope=root}
"

Hi Edi! thanks for replying!

actually this piece of code doesn't work for me. The complete version of my modified template is:

{*?template charset=utf-8?*}
{set-block scope=root variable=subject}{"Collected information from %1"|i18n("design/ezwebin /collectedinfomail/form",,array($collection.object.name|wash))}{/set-block}

{set-block scope=root variable=email_receiver}[email protected]{/set-block}

{def $email_cc_receivers=array('[email protected]') scope=root}

{"Collected Information : "|i18n("design/ezwebin/collectedinfomail/form")}:
{foreach $collection.attributes as $attribute}
{$attribute.contentclass_attribute_name|wash}:
{attribute_result_gui view=info attribute=$attribute}
{/foreach}

i tried also some variant for the new line of code:

... {def $email_cc_receivers='[email protected]' scope=root}

or... {def $email_cc_receiver='[email protected]' scope=root}

but they does nothing, as they would be empty line. Did i miss something in the code, or should i activate some other option somewhere? The version of EZpublish i'm working on is 4.0.1, should i update it?

thanks a lot again!

EDIT: i found this http://share.ez.no/forums/setup-design/cc_in_contact_forms/(from)/ez.no/ that should help, but the patch they refer to is for an older version of EZPublish. Is this feature available in 4.0.1? and by the way is there a patch for this? no basic feature?

Daniele Conci

Friday 31 December 2010 12:29:22 am

Solved my-self!

the right line of code to add cc destinatary is :

{set-block scope=root variable=email_cc_receivers}[email protected]{/set-block}

nothing more, nothing less. For further destinataries use "append-block" instead of "set-block"

Enjoy!

Daniele

Edi Modrić

Friday 31 December 2010 3:32:50 am

"

Solved my-self!

the right line of code to add cc destinatary is :

{set-block scope=root variable=email_cc_receivers}[email protected]{/set-block}

nothing more, nothing less. For further destinataries use "append-block" instead of "set-block"

Enjoy!

Daniele

"

Hi Daniele, yes, that code works fine, I knew about it from before, but it only works for one mail. My intention with previous post was to provide a way to have multiple cc and bcc receivers as there's no obvious way to define multiple cc addresses with set-block and append-block.

Weird thing is, now that I'm trying my piece of code again, it doesn't work. And I could've sworn it was working couple of days ago. :(

Kernel supports receiveing email_cc_receivers variable as an array, and if variable is not an array but a string, it just creates the array with PHP array function. So the solution is obviously to find a way to send email_cc_receivers as an array from template and set-block and append-block can't do that, they can only send the string variables.

I've tried the following code on eZ Publish 4.3 & 4.4 and it didn't work:

{set-block scope=root variable=email_cc_receivers}[email protected]{/set-block}
{foreach array('[email protected]', '[email protected]') as $email}
 {append-block scope=root variable=email_cc_receivers}{$email}{/append-block}
{/foreach}

Now, {set-block scope=root variable=email_cc_receivers}[email protected], [email protected]{/set-block} would be possible with a little kernel hack that replaces the array PHP function with explode PHP function, but I guess that's out of the scope here.

Regarding your question about upgrading eZ Publish, you should definitely do it. 4.0.1 is a version more than two years old.

eZ Publish certified developer

http://ez.no/certification/verify/350658

Edi Modrić

Friday 31 December 2010 3:33:33 am

"
"

Hi Daniele,

you can use email_cc_receivers and email_bcc_receivers persistent variables for that purposes.

Try this example (works well for me):

{set-block scope=root variable=email_receiver}[email protected]{/set-block} 

{def $email_cc_receivers=array('[email protected]', '[email protected]') scope=root}
"

wow! If I learnt it before I should never wrote some extensions just for this purpose, maybe the default feedback form ( from ez web interface or ez flow ) could support it out of box.

"

Yeah, looks like it doesn't work after all :( See my reply to Daniele :)

eZ Publish certified developer

http://ez.no/certification/verify/350658

Daniele Conci

Monday 03 January 2011 12:23:25 am

"
{set-block scope=root variable=email_cc_receivers}[email protected]{/set-block}
{foreach array('[email protected]', '[email protected]') as $email}
 {append-block scope=root variable=email_cc_receivers}{$email}{/append-block}
{/foreach}

Now, {set-block scope=root variable=email_cc_receivers}[email protected], [email protected]{/set-block} would be possible with a little kernel hack that replaces the array PHP function with explode PHP function, but I guess that's out of the scope here.

"

You are completely right Edi, the problem of my code was exactly about the usage of an array var. So the single string for a single cc recipient works, but append doesn't!

regards

Daniele