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} admin@domain.com {/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} admin@domain.com, user@domain.com {/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}admin@domain.com{/set-block} 

{def $email_cc_receivers=array('user1@domain.com', 'user2@domain.com') 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}admin@domain.com{/set-block} 

{def $email_cc_receivers=array('user1@domain.com', 'user2@domain.com') 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}admin@domain.com{/set-block} 

{def $email_cc_receivers=array('user1@domain.com', 'user2@domain.com') 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}admin@domain.com{/set-block}

{def $email_cc_receivers=array('daniele.conci@gmail.com') 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='daniele.conci@gmail.com' scope=root}

or... {def $email_cc_receiver='daniele.conci@gmail.com' 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}user@domain.com{/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}user@domain.com{/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}user@domain.com{/set-block}
{foreach array('user2@domain.com', 'user3@domain.com') as $email}
 {append-block scope=root variable=email_cc_receivers}{$email}{/append-block}
{/foreach}

Now, {set-block scope=root variable=email_cc_receivers}user1@domain.com, user2@domain.com{/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}admin@domain.com{/set-block} 

{def $email_cc_receivers=array('user1@domain.com', 'user2@domain.com') 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}user@domain.com{/set-block}
{foreach array('user2@domain.com', 'user3@domain.com') as $email}
 {append-block scope=root variable=email_cc_receivers}{$email}{/append-block}
{/foreach}

Now, {set-block scope=root variable=email_cc_receivers}user1@domain.com, user2@domain.com{/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

eZ debug

Timing: Jan 18 2025 01:00:24
Script start
Timing: Jan 18 2025 01:00:24
Module start 'content'
Timing: Jan 18 2025 01:00:25
Module end 'content'
Timing: Jan 18 2025 01:00:25
Script end

Main resources:

Total runtime1.5329 sec
Peak memory usage4,096.0000 KB
Database Queries211

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0066 587.9531180.8203
Module start 'content' 0.00661.3872 768.7734705.5938
Module end 'content' 1.39380.1390 1,474.3672349.0391
Script end 1.5328  1,823.4063 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.2718210.0002
Check MTime0.00160.1048210.0001
Mysql Total
Database connection0.00110.071710.0011
Mysqli_queries1.420992.69332110.0067
Looping result0.00210.13892090.0000
Template Total1.503198.120.7516
Template load0.00210.137420.0011
Template processing1.501097.918220.7505
Template load and register function0.00010.009410.0001
states
state_id_array0.00130.084410.0013
state_identifier_array0.00110.074620.0006
Override
Cache load0.00210.13981300.0000
Sytem overhead
Fetch class attribute can translate value0.00160.103340.0004
Fetch class attribute name0.00130.0868100.0001
XML
Image XML parsing0.00260.168940.0006
class_abstraction
Instantiating content class attribute0.00000.0017120.0000
General
dbfile0.00800.5221330.0002
String conversion0.00000.000230.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
27content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
20content/datatype/view/ezxmltags/emphasize.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/emphasize.tplEdit templateOverride template
19content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
7content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
4content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
6content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 99
 Number of unique templates used: 10

Time used to render debug report: 0.0002 secs