How to use ezmail to send email?

Author Message

Bill Smith

Wednesday 03 January 2007 4:15:46 am

I searched the previous posts, and find

$mail = new eZMail();
$mail->setReceiver( 'person@company.com' );
$mail->setSender( 'me@mysite.com' );
$mail->setSubject( 'A nice subject' );
$mail->setBody( 'Here we go' );
$mailResult = eZMailTransport::send( $mail );

but seems it doesn't work

Then I go through the codes of forgotpassword, and try, found that this code works

        $mail = new eZMail();
        $tpl =& templateInit();
        $templateResult =& $tpl->fetch( 'design:user/forgotpasswordmail.tpl' );
        $mail->setSender( $emailSender );
        $mail->setReceiver( $receiver );
        $mail->setSubject( $subject );
        $mail->setBody( $templateResult );
        $mailResult = eZMailTransport::send( $mail );

maybe the body of the email must be fetched from another template?

I am not sure, but when I design a new template, and fetch this template to send email

it doesn't work again. Anyone can tell me how to send the customized mail with

ezPublish? Thanks very much. or can introduce some article on how to send ezmail.

I search the forum, but fail to find. =(

Mingxing Chen

Thursday 04 January 2007 8:25:48 am

Hi Bill,

include_once( 'kernel/classes/ezcontentobject.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/ezcontentbrowse.php' );
include_once( 'kernel/classes/ezcontentbrowsebookmark.php' );
include_once( 'kernel/classes/ezcontentclass.php' );
include_once( "lib/ezdb/classes/ezdb.php" );
include_once( "lib/ezutils/classes/ezhttptool.php" );
include_once( "lib/ezutils/classes/ezini.php" );
include_once( 'kernel/classes/datatypes/ezuser/ezuser.php' );
include_once( 'lib/ezutils/classes/ezmail.php' );
include_once( 'lib/ezutils/classes/ezmailtransport.php' );

Are they useful?
best wishes.

Shinetech is the leader in next generation global application outsourcing. Shinetech combines world class technical skills, recognized expertise in advanced development methodologies and industry experience to deliver results for global enterprises. Shinetech utilizes distributed Agile methods for rapid and precise systems development.
------------------------------------------------------------------------------------------
Blog: http://www.mingxing.me
Email: chenmx@shinetechchina.com

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 18 2025 22:33:02
Script start
Timing: Jan 18 2025 22:33:02
Module start 'layout'
Timing: Jan 18 2025 22:33:02
Module start 'content'
Timing: Jan 18 2025 22:33:02
Module end 'content'
Timing: Jan 18 2025 22:33:02
Script end

Main resources:

Total runtime0.0189 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0080 589.0313152.6250
Module start 'layout' 0.00800.0039 741.656339.4609
Module start 'content' 0.01190.0050 781.117289.4609
Module end 'content' 0.01690.0020 870.578134.3047
Script end 0.0189  904.8828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002513.3630140.0002
Check MTime0.00115.5703140.0001
Mysql Total
Database connection0.00116.001410.0011
Mysqli_queries0.003518.537530.0012
Looping result0.00000.084510.0000
Template Total0.00168.610.0016
Template load0.00084.149710.0008
Template processing0.00084.414410.0008
Override
Cache load0.00052.732910.0005
General
dbfile0.00021.297180.0000
String conversion0.00000.041640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs