Forums / Developer / Sending a mail / Comment69018
Martin Weber
Friday 24 June 2011 8:28:04 am
Your first one can not work:
$mail = new eZMail();$Tpl = eZTemplate::factory();$templateResult = $Tpl->fetch( 'design:info_email.tpl' );$Tpl->setVariable( 'name', 'David' );$subject = 'TEST';$mail->setSender( $emailSender );$mail->setReceiver( 'mymail@mail.com' );$mail->setSubject( $subject );$mail->setBody( $templateResult );$mail->setContentType( 'text/html' );$mailResult = eZMailTransport::send( $mail );
You set the body with the $templateResult. This is returned by fetching the template but you set the variable after fetching.
Regards,Martin