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

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 06:20:35
Script start
Timing: Jan 19 2025 06:20:35
Module start 'layout'
Timing: Jan 19 2025 06:20:35
Module start 'content'
Timing: Jan 19 2025 06:20:36
Module end 'content'
Timing: Jan 19 2025 06:20:36
Script end

Main resources:

Total runtime0.7717 sec
Peak memory usage4,096.0000 KB
Database Queries55

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 589.1563152.6250
Module start 'layout' 0.00480.0022 741.781339.4453
Module start 'content' 0.00700.7622 781.2266483.2266
Module end 'content' 0.76920.0025 1,264.453112.1641
Script end 0.7716  1,276.6172 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.5312160.0003
Check MTime0.00170.2203160.0001
Mysql Total
Database connection0.00060.082410.0006
Mysqli_queries0.710392.0477550.0129
Looping result0.00060.0793530.0000
Template Total0.725694.020.3628
Template load0.00310.400720.0015
Template processing0.722593.625720.3613
Template load and register function0.00010.018010.0001
states
state_id_array0.00170.225710.0017
state_identifier_array0.00260.340020.0013
Override
Cache load0.00260.3307300.0001
Sytem overhead
Fetch class attribute can translate value0.00050.067410.0005
Fetch class attribute name0.00140.179240.0003
XML
Image XML parsing0.00050.063010.0005
class_abstraction
Instantiating content class attribute0.00000.002960.0000
General
dbfile0.00130.1676160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 21
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs