Forums / Developer / newsletter & email workflow

newsletter & email workflow

Author Message

ludo thomas

Tuesday 28 June 2005 7:13:05 am

hi all,
I'm trying to create a simple newsletter system.
I have created a newsletter receivers usergroup.
there is only 3 arguments used:first name, name and email.
with an appropriate template, I can register newsletter receivers.
But my problem is: How to send a confirmation email that just say :"OK, U R registered..!!"

I'try to edit a workflow in Kernel but it's very difficult to understand.

Can someone give me the code to put in my workflow please?
After what I would like to create an other workflow (or notification?) for sending the newletter when I edit a new newsletter....

THANK U

ludo thomas

Tuesday 28 June 2005 9:43:51 am

ok; I have some new elements:
this workflow send a mail, but now I would grab the newsletter receiver email for email receiver..

  $var = phpcode();
function execute( &$process, &$event )
{

$mail = new eZMail();
 			include_once( 'lib/ezutils/classes/ezmail.php' );
            include_once( 'lib/ezutils/classes/ezmailtransport.php' );
			include_once( "lib/ezutils/classes/ezhttptool.php" );
include_once( "kernel/classes/datatypes/ezuser/ezuser.php" );
include_once( "kernel/classes/ezcontentclassattribute.php" );
include_once( "kernel/classes/ezcontentclass.php" );
$user =& eZUser::currentUser();
	 $emailSender ='admin@ez.com';
  	$receiver = 'test@test.com';
  	$body='vous etes bien inscrit à la newsletter!';
            
            $mail->setSender( $emailSender );
            $mail->setReceiver( $receiver );
            $subject = 'inscription à la newsletter ok';
           
            $mail->setSubject( $subject );
            $mail->setBody( $body );
            $mailResult = eZMailTransport::send( $mail );
return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;

}

I have tested something like:

$receiver=$user->attribute( 'email' );

but that doesnt work.

thank U for your help

ludo thomas

Tuesday 05 July 2005 6:03:37 am

ok,
today my workflow is able to send a mail to all the newsletter receivers (class ID=36)

$listeAbonnes = eZContentObject::fetchList( true, 
  array( 'contentclass_id' => 36,
         'status'          =>  EZ_CONTENT_OBJECT_STATUS_PUBLISHED) 
);
	
	
	

foreach($listeAbonnes as $Abonnes){

	$data_map=& $Abonnes->attribute( 'data_map' );
	$email = $data_map['email']->content();
		include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
			include_once( 'lib/ezutils/classes/ezmail.php' );
			$mail = new eZMail();

 			 include_once( "kernel/common/template.php" );
            include_once( 'lib/ezutils/classes/ezmail.php' );
            include_once( 'lib/ezutils/classes/ezmailtransport.php' );
            
			include_once( "kernel/classes/ezcontentclass.php" );
			$nodeID=& eZContentObjectTreeNode::fetch( $nodeID );
			
	$mail_tpl =& templateInit();
	$mail_tpl->setVariable( 'node_id', $nodeID );
	$mailTemplateResult =& $mail_tpl->fetch( 'design:newsletter/newsletter.tpl' );

	$mailTemplateResult =$mailTemplateResult .'zut';
		
		
		 $emailSender ='info@bazaravenue.com';
  		 $receiver = $email;
		
			$mail->setBody( $mailTemplateResult );

            $mail->setSender( $emailSender );		
            $mail->setReceiver( $receiver );
            $subject = 'Nouvelle Newsletter';
           
            $mail->setSubject( $subject );
            //$mail->setBody( $body );
            $mailResult = eZMailTransport::send( $mail );}
//return EZ_WORKFLOW_TYPE_STATUS_ACCEPTED;

but the call of the template (for sending the content of newsletter doesnt work...)
more explanations here:http://ez.no/community/forum/developer/how_to_send_an_object_into_email

eZ debug

Timing: Jan 19 2025 04:27:00
Script start
Timing: Jan 19 2025 04:27:00
Module start 'content'
Timing: Jan 19 2025 04:27:01
Module end 'content'
Timing: Jan 19 2025 04:27:01
Script end

Main resources:

Total runtime0.8665 sec
Peak memory usage4,096.0000 KB
Database Queries192

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0084 590.0703180.8359
Module start 'content' 0.00840.7359 770.9063488.3047
Module end 'content' 0.74430.1221 1,259.2109336.7500
Script end 0.8665  1,595.9609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00510.5880210.0002
Check MTime0.00160.1881210.0001
Mysql Total
Database connection0.00150.173310.0015
Mysqli_queries0.793791.59881920.0041
Looping result0.00190.22071900.0000
Template Total0.831796.020.4159
Template load0.00230.260820.0011
Template processing0.829595.722220.4147
Template load and register function0.00010.011210.0001
states
state_id_array0.00120.135310.0012
state_identifier_array0.00110.123420.0005
Override
Cache load0.00180.2047300.0001
Sytem overhead
Fetch class attribute can translate value0.00130.151220.0007
Fetch class attribute name0.00100.117140.0003
XML
Image XML parsing0.00070.079020.0003
class_abstraction
Instantiating content class attribute0.00000.001560.0000
General
dbfile0.00330.3804270.0001
String conversion0.00000.000630.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
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs