Page 1 of 1

Error sending Email with PEAR!

Posted: Mon May 05, 2008 7:57 am
by highjo
Hit there.Was trying tosend an email from my aplication with PEAR.Actually it send it since i receive it in my localhost admin mail acount but it shows A notice.Here is what it shows.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head>
 
 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>post tile here</title>
</head>
<body>
 
<br>
<b> Notice </b>:  Only variable references should be returned by reference in <b>C:\Program Files\xampp\php\pear\Mail\mime.php</b> on line <b>375</b><br>
<br>
<b> Notice </b>:  Only variable references should be returned by reference in <b>C:\Program Files\xampp\php\pear\Mail\mime.php</b> on line <b>593</b><br>
                <div>Dear customer a Email has been sent to your mail box with the voucher detail</div>
</body></html>
 
this is the actual class code (handle.class.php) in which the function is defined

Code: Select all

 
include_once("Mail.php");
include_once("Mail/mime.php");
 
class handler
{
 
                       private $pdo;
    function __construct($host, $base,$user, $pass)
    {
        try
        {
            $dsn = "mysql:host=$host;dbname=$base";
        
            $this->pdo = new PDO($dsn, $user, $pass);
            $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }
        catch(Exception $e)
        {
            echo "Unexcpected error :" . $e->getMessage();
        }
    }
 
 
                          
            function sendEmail($message,$to,$vouch,$num)
        {
            error_reporting(E_ALL);
            $mime = new Mail_mime("\n");
            $textversion ="Text buddy is glad to send you your text voucher $vouch suscribed through i-wallet. This voucher is valid to send only  $num  sms bought from txtBuddy.
            For sending text message click <a href='#'>Here</a> to send your first text sms with TxtBuddy";
            $mime->setTXTBody($textversion);
            $mime->setHTMLBody($message);
            $header  = array('From'=>'txtBuddy <info@dreamoval.com>', 'Subject' => 'Voucher from TxtBuddy');
            
            $body = $mime->get();
            $header = $mime->headers($header);
            
            $mail = Mail::factory('mail');
            //$to = htmlspecialchars($to);
            $stat = $mail->send($to, $header, $body);
            if(PEAR::isError($stat))
            {
                
                echo "An error Occured sending the mail" . $stat->getMessage();
                
            }
            else
            {
                return "ok";
            }
        }
}
 
And this is where i use it callback.php.As you can see.the function definied in the class return ok if there is no error.
And $mailStatus hold hat returned value and if it's ok it shows the div section in the html with dear customer bla bla bla.

Code: Select all

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>post tile here</title>
</head>
<body>
<?php
    
        //create new handler object to perform database action 
        $h = new handler($db_host,$db_database, $db_user, $db_password);
        $voucherdetail =$h->retrieveVoucherDetails($custrefres);
        
        if($voucherdetail)
        {
            //split cust ref and email into values
            list($custid,$mail,$smsbought) = $voucherdetail;
            //var_dump($voucherdetail);
            
            //issue the voucher now
            $voucheritself=$h->generateRandom(15,1);
            //update database and send email to client
            $h->updateVoucherDetails($voucheritself,$transac_id,$custid);
            $tosend = '<html >
                                <head>
                                    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
                                    <title>Payed voucher number from txtBuddy</title>
                                </head>
 
                                <body style="height:100%;min-height:100%;">
                                    <center>
                                        <div style="width:800px;position:relative;_height:100%;min-height:100%">
                                            <div style="width:600px;height:200px;margin:0 200px 0 200px auto">
                                                <div style="background-color:#4A7CAE;color:#FFFFFF;font-family:Verdana, Arial, Helvetica, sans-serif;font-weight:bold">
                                                    TxtBuddy credit voucher
                                                </div>
                                                <div style="background-color:#E4EFF8;height:180px;color:#F38F5F;">
                                                    Text buddy is glad to send you your text voucher 
                                                    <b style="color:#003399">'. $voucheritself.' </b>
                                                    suscribed through i-wallet. This voucher is valid to send only
                                            '. $smsbought.' sms bought from txtBuddy.For sending text message click
                                                     <a href="#">Here</a> to send your first text sms with TxtBuddy
                                                </div>
                                            </div>
                                        </div>
                                    </center>
                                </body>
                            </html>';
            //pass the variable got from the list function on $voucherdetails which hold the values of the retreiveVoucherDetails call
            $mailstatus=$h->sendEmail($tosend,$mail,$voucheritself,$smsbought);
            if($mailstatus == 'ok')
            {
?>
                <div>Dear customer a Email has been sent to your mail box with the voucher detail</div>
<?php
            }
        }
        
}
?>
</body>
</html>
 
it's actually sendind the mail but the notices are still there.What i have'nt done well here, and how to get rid of it