Forums / Developer / newsletter & email workflow
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
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
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