oxemail.php

Go to the documentation of this file.
00001 <?php
00005 require oxConfig::getInstance()->getConfigParam( 'sCoreDir' ) . "/phpmailer/class.phpmailer.php";
00006 
00007 
00013 class oxEmail extends PHPMailer
00014 {
00020     public $SMTP_PORT = 25;
00021 
00027     protected $_sForgotPwdTemplate = "email_forgotpwd_html.tpl";
00028 
00034     protected $_sForgotPwdTemplatePlain = "email_forgotpwd_plain.tpl";
00035 
00041     protected $_sNewsletterOptInTemplate = "email_newsletteroptin_html.tpl";
00042 
00048     protected $_sNewsletterOptInTemplatePlain = "email_newsletteroptin_plain.tpl";
00049 
00055     protected $_sSuggestTemplate = "email_suggest_html.tpl";
00056 
00062     protected $_sSuggestTemplatePlain = "email_suggest_plain.tpl";
00063 
00069     protected $_sSenedNowTemplate = "email_sendednow_html.tpl";
00070 
00076     protected $_sSenedNowTemplatePlain = "email_sendednow_plain.tpl";
00077 
00083     protected $_sWishListTemplate = "email_wishlist_html.tpl";
00084 
00090     protected $_sWishListTemplatePlain = "email_wishlist_plain.tpl";
00091 
00097     protected $_sRegisterTemplate = "email_register_html.tpl";
00098 
00104     protected $_sRegisterTemplatePlain = "email_register_plain.tpl";
00105 
00111     protected $_sReminderMailTemplate = "email_owner_reminder_html.tpl";
00112 
00118     protected $_sOrderUserTemplate          = "email_order_cust_html.tpl";
00119 
00125     protected $_sOrderUserPlainTemplate     = "email_order_cust_plain.tpl";
00126 
00132     protected $_sOrderOwnerTemplate         = "email_order_owner_html.tpl";
00133 
00139     protected $_sOrderOwnerPlainTemplate    = "email_order_owner_plain.tpl";
00140 
00141     // #586A - additional templates for more customizable subjects
00142 
00148     protected $_sOrderUserSubjectTemplate   = "email_order_cust_subj.tpl";
00149 
00155     protected $_sOrderOwnerSubjectTemplate  = "email_order_owner_subj.tpl";
00156 
00162     protected $_sOwnerPricealarmTemplate    = "email_pricealarm_owner.tpl";
00163 
00169     protected $_aShops = array();
00170 
00176     protected $_blInlineImgEmail = null;
00177 
00183     protected $_aRecipients = array();
00184 
00190     protected $_aReplies = array();
00191 
00197     protected $_aAttachments = array();
00198 
00202     public function __construct()
00203     {
00204         //enabling exception handling in phpmailer class
00205         parent::__construct( true );
00206 
00207         $myConfig = $this->getConfig();
00208 
00209         $this->_setMailerPluginDir();
00210         $this->setSmtp();
00211 
00212         $this->setUseInlineImages( $myConfig->getConfigParam('blInlineImgEmail') );
00213         $this->setMailWordWrap( 100 );
00214 
00215         $this->isHtml( true );
00216         $this->setLanguage( "en", $myConfig->getConfigParam( 'sShopDir' )."/core/phpmailer/language/");
00217     }
00218 
00230     public function __call( $sMethod, $aArgs )
00231     {
00232         if ( defined( 'OXID_PHP_UNIT' ) ) {
00233             if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00234                 $sMethod = str_replace( "UNIT", "_", $sMethod );
00235             }
00236             if ( method_exists( $this, $sMethod)) {
00237                 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00238             }
00239         }
00240 
00241         throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00242     }
00243 
00249     public function getConfig()
00250     {
00251         if ( $this->_oConfig == null ) {
00252             $this->_oConfig = oxConfig::getInstance();
00253         }
00254 
00255         return $this->_oConfig;
00256     }
00257 
00265     public function setConfig( $oConfig )
00266     {
00267         $this->_oConfig = $oConfig;
00268     }
00269 
00277     public function send()
00278     {
00279         // if no recipients found, skipping sending
00280         if ( count( $this->getRecipient() ) < 1 ) {
00281             return false;
00282         }
00283 
00284         $myConfig = $this->getConfig();
00285         $this->setCharSet();
00286 
00287         if ( $this->_getUseInlineImages() ) {
00288             $this->_includeImages( $myConfig->getImageDir(), $myConfig->getNoSSLImageDir( isAdmin() ), $myConfig->getDynImageDir(),
00289                                    $myConfig->getAbsImageDir(), $myConfig->getAbsDynImageDir());
00290         }
00291 
00292         $this->_makeOutputProcessing();
00293 
00294         // try to send mail via SMTP
00295         if ( $this->getMailer() == 'smtp' ) {
00296             $blRet = $this->_sendMail();
00297 
00298             // if sending failed, try to send via mail()
00299             if ( !$blRet ) {
00300                 $this->setMailer( 'mail' );
00301                 $blRet = $this->_sendMail();
00302             }
00303         } else {
00304             // sending mail via mail()
00305             $this->setMailer( 'mail' );
00306             $blRet = $this->_sendMail();
00307         }
00308 
00309         if ( !$blRet ) {
00310             // failed sending, giving up, trying to send notification to shop owner
00311             $this->_sendMailErrorMsg();
00312         }
00313 
00314         return $blRet;
00315     }
00316 
00325     protected function _setSmtpProtocol($sUrl)
00326     {
00327         $sProtocol = '';
00328         $sSmtpHost = $sUrl;
00329         if ( getStr()->preg_match('@^([0-9a-z]+://)?(.*)$@i', $sUrl, $m ) ) {
00330             if ($m[1]) {
00331                 if (($m[1] == 'ssl://') || ($m[1] == 'tls://')) {
00332                     $this->set( "SMTPSecure", substr($m[1], 0, 3) );
00333                 } else {
00334                     $sProtocol = $m[1];
00335                 }
00336             }
00337             $sSmtpHost = $m[2];
00338         }
00339 
00340         return $sProtocol.$sSmtpHost;
00341     }
00342 
00350     public function setSmtp( $oShop = null )
00351     {
00352         $myConfig = $this->getConfig();
00353         $oShop = ( $oShop ) ? $oShop : $this->_getShop();
00354 
00355         $sSmtpUrl = $this->_setSmtpProtocol($oShop->oxshops__oxsmtp->value);
00356 
00357         if ( !$this->_isValidSmtpHost( $sSmtpUrl ) ) {
00358             $this->setMailer( "mail" );
00359             return;
00360         }
00361 
00362         $this->setHost( $sSmtpUrl );
00363         $this->setMailer( "smtp" );
00364 
00365         if ( $oShop->oxshops__oxsmtpuser->value ) {
00366             $this->_setSmtpAuthInfo( $oShop->oxshops__oxsmtpuser->value, $oShop->oxshops__oxsmtppwd->value );
00367         }
00368 
00369         if ( $myConfig->getConfigParam( 'iDebug' ) == 6 ) {
00370             $this->_setSmtpDebug( true );
00371         }
00372     }
00373 
00381     protected function _isValidSmtpHost( $sSmtpHost )
00382     {
00383         $blIsSmtp = false;
00384         if ( $sSmtpHost ) {
00385             $sSmtpPort = $this->SMTP_PORT;
00386             if ( getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $sSmtpHost, $m)) {
00387                 $sSmtpHost = $m[1];
00388                 $sSmtpPort = (int)$m[3];
00389                 if (!$sSmtpPort) {
00390                     $sSmtpPort = $this->SMTP_PORT;
00391                 }
00392             }
00393             if ( $blIsSmtp = (bool) ( $rHandle = @fsockopen( $sSmtpHost, $sSmtpPort, $iErrNo, $sErrStr, 30 )) ) {
00394                 // closing connection ..
00395                 fclose( $rHandle );
00396             }
00397         }
00398 
00399         return $blIsSmtp;
00400     }
00401 
00411     public function sendOrderEmailToUser( $oOrder, $sSubject = null )
00412     {
00413         $myConfig = $this->getConfig();
00414 
00415         // add user defined stuff if there is any
00416         $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00417 
00418         //set mail params (from, fromName, smtp)
00419         $oShop = $this->_getShop();
00420         $this->_setMailParams( $oShop );
00421 
00422         // P
00423         // setting some deprecated variables
00424         $oOrder->oDelSet = $oOrder->getDelSet();
00425 
00426         $oUser = $oOrder->getOrderUser();
00427         // create messages
00428         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00429         $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00430         $oSmarty->assign( "order", $oOrder);
00431         $oSmarty->assign( "shop", $oShop );
00432         $oSmarty->assign( "oViewConf", $oShop );
00433         $oSmarty->assign( "oView", $myConfig->getActiveView() );
00434         $oSmarty->assign( "user", $oUser );
00435         $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00436         $oSmarty->assign( "basket", $oOrder->getBasket() );
00437         $oSmarty->assign( "payment", $oOrder->getPayment() );
00438         if ( $oUser ) {
00439             $oSmarty->assign( "reviewuser", $oUser->getReviewUserHash( $oUser->getId() ) );
00440         }
00441         $oSmarty->assign( "paymentinfo", $myConfig->getActiveShop() );
00442 
00443         //deprecated vars
00444         $oSmarty->assign( "iswishlist", true );
00445         $oSmarty->assign( "isreview", true );
00446 
00447         if ( $aVoucherList = $oOrder->getVoucherList() ) {
00448             $oSmarty->assign( "vouchers", $aVoucherList );
00449         }
00450 
00451         $oOutputProcessor = oxNew( "oxoutput" );
00452         $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00453 
00454         foreach ( $aNewSmartyArray as $key => $val ) {
00455             $oSmarty->assign( $key, $val );
00456         }
00457 
00458         $this->setBody( $oSmarty->fetch( $this->_sOrderUserTemplate ) );
00459         $this->setAltBody( $oSmarty->fetch( $this->_sOrderUserPlainTemplate ) );
00460 
00461         // #586A
00462         if ( $sSubject === null ) {
00463             if ( $oSmarty->template_exists( $this->_sOrderUserSubjectTemplate) ) {
00464                 $sSubject = $oSmarty->fetch( $this->_sOrderUserSubjectTemplate );
00465             } else {
00466                 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00467             }
00468         }
00469 
00470         $this->setSubject( $sSubject );
00471 
00472         $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00473 
00474         $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00475         $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00476 
00477         $blSuccess = $this->send();
00478 
00479         return $blSuccess;
00480     }
00481 
00491     public function sendOrderEmailToOwner( $oOrder, $sSubject = null )
00492     {
00493         $myConfig = $this->getConfig();
00494 
00495         $oShop = $this->_getShop();
00496 
00497         // cleanup
00498         $this->_clearMailer();
00499 
00500         // add user defined stuff if there is any
00501         $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00502 
00503         // send confirmation to shop owner
00504         $sFullName = $oOrder->getOrderUser()->oxuser__oxfname->getRawValue() . " " . $oOrder->getOrderUser()->oxuser__oxlname->getRawValue();
00505         $this->setFrom( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00506 
00507         $oLang = oxLang::getInstance();
00508         $iOrderLang = $oLang->getObjectTplLanguage();
00509 
00510         // if running shop language is different from admin lang. set in config
00511         // we have to load shop in config language
00512         if ( $oShop->getLanguage() != $iOrderLang ) {
00513             $oShop = $this->_getShop( $iOrderLang );
00514         }
00515 
00516         $this->setSmtp( $oShop );
00517 
00518         // create messages
00519         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00520         $oSmarty->assign( "charset", $oLang->translateString("charset"));
00521         $oSmarty->assign( "order", $oOrder );
00522         $oSmarty->assign( "shop", $oShop );
00523         $oSmarty->assign( "oViewConf", $oShop );
00524         $oSmarty->assign( "oView", $myConfig->getActiveView() );
00525         $oSmarty->assign( "user", $oOrder->getOrderUser() );
00526         $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00527         $oSmarty->assign( "basket", $oOrder->getBasket() );
00528         $oSmarty->assign( "payment", $oOrder->getPayment() );
00529 
00530         //deprecated var
00531         $oSmarty->assign( "iswishlist", true);
00532 
00533         if( $oOrder->getVoucherList() )
00534             $oSmarty->assign( "vouchers", $oOrder->getVoucherList() );
00535 
00536         $oOutputProcessor = oxNew( "oxoutput" );
00537         $aNewSmartyArray = $oOutputProcessor->processViewArray($oSmarty->get_template_vars(), "oxemail");
00538         foreach ($aNewSmartyArray as $key => $val)
00539             $oSmarty->assign( $key, $val );
00540 
00541         $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerTemplate, false ) ) );
00542         $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerPlainTemplate, false ) ) );
00543 
00544         //Sets subject to email
00545         // #586A
00546         if ( $sSubject === null ) {
00547             if ( $oSmarty->template_exists( $this->_sOrderOwnerSubjectTemplate) ) {
00548                 $sSubject = $oSmarty->fetch( $this->_sOrderOwnerSubjectTemplate );
00549             } else {
00550                  $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00551             }
00552         }
00553 
00554         $this->setSubject( $sSubject );
00555         $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oLang->translateString("order") );
00556 
00557         if ( $oOrder->getOrderUser()->oxuser__oxusername->value != "admin" )
00558             $this->setReplyTo( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00559 
00560         $blSuccess = $this->send();
00561 
00562         // add user history
00563         $oRemark = oxNew( "oxremark" );
00564         $oRemark->oxremark__oxtext      = new oxField($this->getAltBody(), oxField::T_RAW);
00565         $oRemark->oxremark__oxparentid  = new oxField($oOrder->getOrderUser()->getId(), oxField::T_RAW);
00566         $oRemark->oxremark__oxtype      = new oxField("o", oxField::T_RAW);
00567         $oRemark->save();
00568 
00569 
00570         if ( $myConfig->getConfigParam( 'iDebug' ) == 6) {
00571             oxUtils::getInstance()->showMessageAndExit( "" );
00572         }
00573 
00574         return $blSuccess;
00575     }
00576 
00586     public function sendRegisterEmail( $oUser, $sSubject = null )
00587     {
00588         // add user defined stuff if there is any
00589         $oUser = $this->_addUserRegisterEmail( $oUser );
00590 
00591         // shop info
00592         $oShop = $this->_getShop();
00593 
00594         //set mail params (from, fromName, smtp )
00595         $this->_setMailParams( $oShop );
00596 
00597         // create messages
00598         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00599         $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00600         $oSmarty->assign( "shop", $oShop );
00601         $oSmarty->assign( "oViewConf", $oShop );
00602         $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00603         $oSmarty->assign( "user", $oUser );
00604 
00605         $oOutputProcessor = oxNew( "oxoutput" );
00606         $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00607 
00608         foreach ( $aNewSmartyArray as $key => $val ) {
00609             $oSmarty->assign( $key, $val );
00610         }
00611 
00612         $this->setBody( $oSmarty->fetch( $this->_sRegisterTemplate ) );
00613         $this->setAltBody( $oSmarty->fetch( $this->_sRegisterTemplatePlain ) );
00614 
00615         $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue() );
00616 
00617         $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00618 
00619         $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00620         $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00621 
00622         return $this->send();
00623     }
00624 
00634     public function sendForgotPwdEmail( $sEmailAddress, $sSubject = null )
00635     {
00636         $myConfig = $this->getConfig();
00637         $oDb = oxDb::getDb();
00638 
00639         // shop info
00640         $oShop = $this->_getShop();
00641 
00642         // add user defined stuff if there is any
00643         $oShop = $this->_addForgotPwdEmail( $oShop);
00644 
00645         //set mail params (from, fromName, smtp)
00646         $this->_setMailParams( $oShop );
00647 
00648         // user
00649         $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sEmailAddress )." and oxuser.oxpassword != ''";
00650         $sOrder = "";
00651         if ( $myConfig->getConfigParam( 'blMallUsers' )) {
00652             $sOrder = "order by oxshopid = '".$oShop->getId()."' desc";
00653         } else {
00654             $sWhere .= " and oxshopid = '".$oShop->getId()."'";
00655         }
00656 
00657         $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00658         if ( ( $sOxId = $oDb->getOne( $sSelect ) ) ) {
00659 
00660             $oUser = oxNew( 'oxuser' );
00661             if ( $oUser->load($sOxId) ) {
00662                 // create messages
00663                 $oSmarty = oxUtilsView::getInstance()->getSmarty();
00664                 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00665                 $oSmarty->assign( "shop", $oShop );
00666                 $oSmarty->assign( "oViewConf", $oShop );
00667                 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00668                 $oSmarty->assign( "user", $oUser );
00669 
00670                 $oOutputProcessor = oxNew( "oxoutput" );
00671                 $aNewSmartyArray  = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00672 
00673                 foreach ( $aNewSmartyArray as $key => $val ) {
00674                     $oSmarty->assign($key, $val);
00675                 }
00676 
00677                 $this->setBody( $oSmarty->fetch( $this->_sForgotPwdTemplate ) );
00678                 $this->setAltBody( $oSmarty->fetch( $this->_sForgotPwdTemplatePlain ) );
00679 
00680                 //sets subject of email
00681                 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue() );
00682 
00683                 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00684 
00685                 $this->setRecipient( $sEmailAddress, $sFullName );
00686                 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00687 
00688                 return $this->send();
00689             }
00690         }
00691 
00692         return false;
00693     }
00694 
00705     public function sendContactMail( $sEmailAddress = null, $sSubject = null, $sMessage = null )
00706     {
00707 
00708         // shop info
00709         $oShop = $this->_getShop();
00710 
00711         //set mail params (from, fromName, smtp)
00712         $this->_setMailParams( $oShop );
00713 
00714         $this->setBody( $sMessage );
00715         $this->setSubject( $sSubject );
00716 
00717         $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00718         $this->setFrom( $sEmailAddress, "" );
00719         $this->setReplyTo( $sEmailAddress, "" );
00720 
00721         return $this->send();
00722     }
00723 
00733     public function sendNewsletterDbOptInMail( $oUser, $sSubject = null )
00734     {
00735         $oLang = oxLang::getInstance();
00736 
00737         // add user defined stuff if there is any
00738         $oUser = $this->_addNewsletterDbOptInMail( $oUser );
00739 
00740         // shop info
00741         $oShop = $this->_getShop();
00742 
00743         //set mail params (from, fromName, smtp)
00744         $this->_setMailParams( $oShop );
00745 
00746         // create messages
00747         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00748         $oSmarty->assign( "charset", $oLang->translateString("charset"));
00749         $oSmarty->assign( "shop", $oShop );
00750         $oSmarty->assign( "oViewConf", $oShop );
00751         $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00752         $oSmarty->assign( "subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value) );
00753         $oSmarty->assign( "user", $oUser );
00754 
00755         $oOutputProcessor = oxNew( "oxoutput" );
00756         $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00757         foreach ( $aNewSmartyArray as $key => $val ) {
00758             $oSmarty->assign( $key, $val );
00759         }
00760 
00761         $this->setBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplate ) );
00762         $this->setAltBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplatePlain ) );
00763         $this->setSubject( ( $sSubject !== null ) ? $sSubject : oxLang::getInstance()->translateString("EMAIL_NEWSLETTERDBOPTINMAIL_SUBJECT") . " " . $oShop->oxshops__oxname->getRawValue() );
00764 
00765         $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00766 
00767         $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00768         $this->setFrom( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00769         $this->setReplyTo( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00770 
00771         return $this->send();
00772     }
00773 
00781     protected function _getNewsSubsLink( $sId )
00782     {
00783         $myConfig = $this->getConfig();
00784         $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00785 
00786         $sUrl      = $myConfig->getShopHomeURL().'cl=newsletter&amp;fnc=addme&amp;uid='.$sId.$sLang;
00787         $sUrl .= ( $iActShopLang ) ? '&amp;lang='.$iActShopLang : "";
00788         return $sUrl;
00789     }
00790 
00801     public function sendNewsletterMail( $oNewsLetter, $oUser, $sSubject = null )
00802     {
00803         // shop info
00804         $oShop = $this->_getShop();
00805 
00806         //set mail params (from, fromName, smtp)
00807         $this->_setMailParams( $oShop );
00808 
00809         $sBody = $oNewsLetter->getHtmlText();
00810 
00811         if ( !empty($sBody) ) {
00812             $this->setBody( $sBody );
00813             $this->setAltBody( $oNewsLetter->getPlainText() );
00814         } else {
00815             $this->isHtml( false );
00816             $this->setBody( $oNewsLetter->getPlainText() );
00817         }
00818 
00819         $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue() );
00820 
00821         $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00822         $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00823         $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00824 
00825         return $this->send();
00826     }
00827 
00837     public function sendSuggestMail( $oParams, $oProduct )
00838     {
00839         $myConfig = $this->getConfig();
00840 
00841         //sets language of shop
00842         $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00843 
00844         // shop info
00845         $oShop = $this->_getShop( $iCurrLang );
00846 
00847         //sets language to article
00848         if ( $oProduct->getLanguage() != $iCurrLang ) {
00849             $oProduct->setLanguage( $iCurrLang );
00850             $oProduct->load( $oProduct->getId() );
00851         }
00852 
00853         // mailer stuff
00854         $this->setFrom( $oParams->send_email, $oParams->send_name );
00855         $this->setSMTP();
00856 
00857         // create messages
00858         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00859         $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00860         $oSmarty->assign( "shop", $oShop );
00861         $oSmarty->assign( "oViewConf", $oShop );
00862         $oSmarty->assign( "oView", $myConfig->getActiveView() );
00863         $oSmarty->assign( "userinfo", $oParams );
00864         $oSmarty->assign( "product", $oProduct );
00865 
00866         $oOutputProcessor = oxNew( "oxoutput" );
00867         $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00868 
00869         foreach ( $aNewSmartyArray as $key => $val ) {
00870             $oSmarty->assign( $key, $val );
00871         }
00872 
00873         $this->setBody( $oSmarty->fetch( $this->_sSuggestTemplate ) );
00874         $this->setAltBody( $oSmarty->fetch( $this->_sSuggestTemplatePlain ) );
00875         $this->setSubject( $oParams->send_subject );
00876 
00877         $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
00878         $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00879 
00880         return $this->send();
00881     }
00882 
00892     public function sendSendedNowMail( $oOrder, $sSubject = null )
00893     {
00894         $myConfig = $this->getConfig();
00895 
00896         $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
00897 
00898         // shop info
00899         $oShop = $this->_getShop( $iOrderLang );
00900 
00901         //set mail params (from, fromName, smtp)
00902         $this->_setMailParams( $oShop );
00903 
00904         //override default wrap
00905         //$this->setMailWordWrap( 0 );
00906 
00907         //create messages
00908         $oLang = oxLang::getInstance();
00909         $oSmarty = oxUtilsView::getInstance()->getSmarty();
00910         $oSmarty->assign( "charset", $oLang->translateString("charset"));
00911         $oSmarty->assign( "shop", $oShop );
00912         $oSmarty->assign( "oViewConf", $oShop );
00913         $oSmarty->assign( "oView", $myConfig->getActiveView() );
00914         $oSmarty->assign( "order", $oOrder );
00915         $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00916 
00917         //deprecated var
00918         $oSmarty->assign( "isreview", true);
00919         $oUser = oxNew( 'oxuser' );
00920         $oSmarty->assign( "reviewuser", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
00921 
00922         $oOutputProcessor = oxNew( "oxoutput" );
00923         $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00924 
00925         foreach ( $aNewSmartyArray as $key => $val ) {
00926             $oSmarty->assign( $key, $val );
00927         }
00928 
00929         // dodger #1469 - we need to patch security here as we do not use standard template dir, so smarty stops working
00930         $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
00931         //V send email in order language
00932         $iOldTplLang = $oLang->getTplLanguage();
00933         $iOldBaseLang = $oLang->getTplLanguage();
00934         $oLang->setTplLanguage( $iOrderLang );
00935         $oLang->setBaseLanguage( $iOrderLang );
00936 
00937         $oSmarty->security_settings['INCLUDE_ANY'] = true;
00938 
00939         $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplate, false ) ) );
00940         $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplatePlain, false ) ) );
00941         $oLang->setTplLanguage( $iOldTplLang );
00942         $oLang->setBaseLanguage( $iOldBaseLang );
00943         // set it back
00944         $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
00945 
00946         //Sets subject to email
00947         $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue() );
00948 
00949         $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
00950 
00951         $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
00952         $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00953         return $this->send();
00954     }
00955 
00970     public function sendBackupMail( $aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError )
00971     {
00972 
00973         /* P
00974         $sMailMessage = $myConfig->getConfigParam( 'sMailMessage' );
00975         $sMessage = ( !empty($sMailMessage) ) ? $sMailMessage : "" ;
00976         */
00977 
00978         // shop info
00979         $oShop = $this->_getShop();
00980 
00981         //set mail params (from, fromName, smtp)
00982         $this->_setMailParams( $oShop );
00983 
00984         $this->setBody( $sMessage );
00985         $this->setSubject( $sSubject );
00986 
00987         $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00988         $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
00989 
00990         $this->setFrom( $sEmailAddress, "" );
00991         $this->setReplyTo( $sEmailAddress, "" );
00992 
00993         //attaching files
00994         $blAttashSucc = true;
00995         $sAttPath = oxUtilsFile::getInstance()->normalizeDir($sAttPath);
00996         foreach ( $aAttFiles as $iNum => $sAttFile ) {
00997             if ( file_exists($sAttPath . $sAttFile) && is_file($sAttPath . $sAttFile) ) {
00998                 $blAttashSucc = $this->addAttachment( $sAttPath, $sAttFile );
00999             } else {
01000                 $blAttashSucc = false;
01001                 $aError[] = array( 5, $sAttFile );   //"Error: backup file $sAttFile not found";
01002             }
01003         }
01004 
01005         if ( !$blAttashSucc ) {
01006             $aError[] = array( 4, "" );   //"Error: backup files was not sent to email ...";
01007             $this->clearAttachments();
01008             return false;
01009         }
01010 
01011         $aStatus[] = 3;     //"Mailing backup files ...";
01012         $blSend = $this->send();
01013         $this->clearAttachments();
01014 
01015         return $blSend;
01016     }
01017 
01028     public function sendEmail( $sTo, $sSubject, $sBody )
01029     {
01030         //set mail params (from, fromName, smtp)
01031         $this->_setMailParams();
01032 
01033         if ( is_array($sTo) ) {
01034             foreach ($sTo as $sAddress) {
01035                 $this->setRecipient( $sAddress, "" );
01036                 $this->setReplyTo( $sAddress, "" );
01037             }
01038         } else {
01039             $this->setRecipient( $sTo, "" );
01040             $this->setReplyTo( $sTo, "" );
01041         }
01042 
01043         //may be changed later
01044         $this->isHtml( false );
01045 
01046         $this->setSubject( $sSubject );
01047         $this->setBody( $sBody );
01048 
01049         return $this->send();
01050     }
01051 
01060     public function sendStockReminder( $aBasketContents, $sSubject = null )
01061     {
01062         $blSend = false;
01063 
01064         $oArticleList = oxNew( "oxarticlelist" );
01065         $oArticleList->loadStockRemindProducts( $aBasketContents );
01066 
01067         // nothing to remind?
01068         if ( $oArticleList->count() ) {
01069             $oShop = $this->_getShop();
01070 
01071             //set mail params (from, fromName, smtp... )
01072             $this->_setMailParams( $oShop );
01073             $oLang = oxLang::getInstance();
01074 
01075             $oSmarty = oxUtilsView::getInstance()->getSmarty();
01076             $oSmarty->assign( "charset", $oLang->translateString( "charset" ) );
01077             $oSmarty->assign( "shop", $oShop );
01078             $oSmarty->assign( "oViewConf", $oShop );
01079             $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01080             $oSmarty->assign( "articles", $oArticleList );
01081 
01082             $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01083             $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01084             $this->setBody( $oSmarty->fetch( $this->getConfig()->getTemplatePath( $this->_sReminderMailTemplate, false ) ) );
01085             $this->setAltBody( "" );
01086             $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_STOCKREMINDER_SUBJECT' ) );
01087 
01088             $blSend = $this->send();
01089         }
01090 
01091         return $blSend;
01092     }
01093 
01102     public function sendWishlistMail( $oParams )
01103     {
01104         $myConfig = $this->getConfig();
01105 
01106         $this->_clearMailer();
01107 
01108         // shop info
01109         $oShop = $this->_getShop();
01110 
01111         // mailer stuff
01112         $this->setFrom( $oParams->send_email, $oParams->send_name );
01113         $this->setSMTP();
01114 
01115         // create messages
01116         $oSmarty = oxUtilsView::getInstance()->getSmarty();
01117         $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
01118         $oSmarty->assign( "shop", $oShop );
01119         $oSmarty->assign( "oViewConf", $oShop );
01120         $oSmarty->assign( "oView", $myConfig->getActiveView() );
01121         $oSmarty->assign( "userinfo", $oParams );
01122 
01123         $this->setBody( $oSmarty->fetch( $this->_sWishListTemplate ) );
01124         $this->setAltBody( $oSmarty->fetch( $this->_sWishListTemplatePlain ) );
01125         $this->setSubject( $oParams->send_subject );
01126 
01127         $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
01128         $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01129 
01130         return $this->send();
01131     }
01132 
01143     public function sendPriceAlarmNotification( $aParams, $oAlarm, $sSubject = null )
01144     {
01145         $this->_clearMailer();
01146         $oShop = $this->_getShop();
01147 
01148         //set mail params (from, fromName, smtp)
01149         $this->_setMailParams( $oShop );
01150 
01151         $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01152 
01153         $oArticle = oxNew( "oxarticle" );
01154         $oArticle->setSkipAbPrice( true );
01155         $oArticle->loadInLang( $iAlarmLang, $aParams['aid'] );
01156 
01157         $oCur  = $this->getConfig()->getActShopCurrencyObject();
01158         $oLang = oxLang::getInstance();
01159 
01160         // create messages
01161         $oSmarty = oxUtilsView::getInstance()->getSmarty();
01162         $oSmarty->assign( "shop", $oShop );
01163         $oSmarty->assign( "oViewConf", $oShop );
01164         $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01165         $oSmarty->assign( "product", $oArticle );
01166         $oSmarty->assign( "email", $aParams['email']);
01167         $oSmarty->assign( "bidprice", $oLang->formatCurrency( $oAlarm->oxpricealarm__oxprice->value, $oCur ) );
01168         $oSmarty->assign( "currency", $oCur );
01169 
01170         $this->setRecipient( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01171         $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_PRICEALARM_OWNER_SUBJECT', $iAlarmLang ) . " " . $oArticle->oxarticles__oxtitle->getRawValue() );
01172         $this->setBody( $oSmarty->fetch( $this->_sOwnerPricealarmTemplate ) );
01173         $this->setFrom( $aParams['email'], "" );
01174         $this->setReplyTo( $aParams['email'], "" );
01175 
01176         return $this->send();
01177     }
01178 
01190     protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01191     {
01192         $sBody = $this->getBody();
01193         if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01194 
01195             $oFileUtils = oxUtilsFile::getInstance();
01196             $blReSetBody = false;
01197 
01198             // preparing imput
01199             $sDynImageDir = $oFileUtils->normalizeDir( $sDynImageDir );
01200             $sImageDir = $oFileUtils->normalizeDir( $sImageDir );
01201             $sImageDirNoSSL = $oFileUtils->normalizeDir( $sImageDirNoSSL );
01202 
01203             if (is_array($matches) && count($matches)) {
01204                 $aImageCache = array();
01205                 $myUtils = oxUtils::getInstance();
01206                 $myUtilsObject = oxUtilsObject::getInstance();
01207 
01208                 foreach ($matches as $aImage) {
01209 
01210                     $image = $aImage[1];
01211                     $sFileName = '';
01212                     if ( strpos( $image, $sDynImageDir ) === 0 ) {
01213                         $sFileName = $oFileUtils->normalizeDir( $sAbsDynImageDir ) . str_replace( $sDynImageDir, '', $image );
01214                     } elseif ( strpos( $image, $sImageDir ) === 0 ) {
01215                         $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDir, '', $image );
01216                     } elseif ( strpos( $image, $sImageDirNoSSL ) === 0 ) {
01217                         $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDirNoSSL, '', $image );
01218                     }
01219 
01220                     if ($sFileName && @is_file($sFileName)) {
01221                         $sCId = '';
01222                         if ( isset( $aImageCache[$sFileName] ) && $aImageCache[$sFileName] ) {
01223                             $sCId = $aImageCache[$sFileName];
01224                         } else {
01225                             $sCId = $myUtilsObject->generateUID();
01226                             $sMIME = $myUtils->oxMimeContentType($sFileName);
01227                             if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01228                                 if ( $this->addEmbeddedImage( $sFileName, $sCId, "image", "base64", $sMIME ) ) {
01229                                     $aImageCache[$sFileName] = $sCId;
01230                                 } else {
01231                                     $sCId = '';
01232                                 }
01233                             }
01234                         }
01235                         if ( $sCId && $sCId == $aImageCache[$sFileName] ) {
01236                             if ( $sReplTag = str_replace( $image, 'cid:'.$sCId, $aImage[0] ) ) {
01237                                 $sBody = str_replace($aImage[0], $sReplTag, $sBody );
01238                                 $blReSetBody = true;
01239                             }
01240                         }
01241                     }
01242                 }
01243             }
01244 
01245             if ( $blReSetBody ) {
01246                 $this->setBody( $sBody );
01247             }
01248         }
01249     }
01250 
01258     public function setSubject( $sSubject = null )
01259     {
01260         // A. HTML entites in subjects must be replaced
01261         $sSubject = str_replace(array('&amp;', '&quot;', '&#039;', '&lt;', '&gt;'), array('&', '"', "'", '<', '>' ), $sSubject);
01262 
01263         $this->set( "Subject", $sSubject );
01264     }
01265 
01271     public function getSubject()
01272     {
01273         return $this->Subject;
01274     }
01275 
01285     public function setBody( $sBody = null, $blClearSid = true )
01286     {
01287         if ( $blClearSid ) {
01288             $sBody = getStr()->preg_replace("/sid=[A-Z0-9\.]+/i", "sid=x&amp;shp=" . $this->getConfig()->getShopId(), $sBody);
01289         }
01290 
01291         $this->set( "Body", $sBody );
01292     }
01293 
01299     public function getBody()
01300     {
01301         return $this->Body;
01302     }
01303 
01313     public function setAltBody( $sAltBody = null, $blClearSid = true )
01314     {
01315         if ( $blClearSid ) {
01316             $sAltBody = getStr()->preg_replace("/sid=[A-Z0-9\.]+/i", "sid=x&amp;shp=" . $this->getConfig()->getShopId(), $sAltBody);
01317         }
01318 
01319         // A. alt body is used for plain text emails so we should eliminate HTML entities
01320         $sAltBody = str_replace(array('&amp;', '&quot;', '&#039;', '&lt;', '&gt;'), array('&', '"', "'", '<', '>' ), $sAltBody);
01321 
01322         $this->set( "AltBody", $sAltBody );
01323     }
01324 
01330     public function getAltBody()
01331     {
01332         return $this->AltBody;
01333     }
01334 
01343     public function setRecipient( $sAddress = null, $sName = null )
01344     {
01345         try {
01346             parent::AddAddress( $sAddress, $sName );
01347 
01348             // copying values as original class does not allow to access recipients array
01349             $this->_aRecipients[] = array( $sAddress, $sName );
01350         } catch( Exception $oEx ) {
01351         }
01352     }
01353 
01361     public function getRecipient()
01362     {
01363         return $this->_aRecipients;
01364     }
01365 
01372     public function clearAllRecipients()
01373     {
01374         $this->_aRecipients = array();
01375         parent::clearAllRecipients();
01376     }
01377 
01389     public function setReplyTo( $sEmail = null, $sName = null )
01390     {
01391         if ( !oxUtils::getInstance()->isValidEmail( $sEmail ) ) {
01392             $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01393         }
01394 
01395         $this->_aReplies[] = array( $sEmail, $sName );
01396 
01397         try {
01398             parent::addReplyTo( $sEmail, $sName );
01399         } catch( Exception $oEx ) {
01400         }
01401     }
01402 
01408     public function getReplyTo()
01409     {
01410         return $this->_aReplies;
01411     }
01412 
01418     public function clearReplyTos()
01419     {
01420         $this->_aReplies = array();
01421         parent::clearReplyTos();
01422     }
01423 
01432     public function setFrom( $sFromAdress, $sFromName = null )
01433     {
01434         // preventing possible email spam over php mail() exploit (http://www.securephpwiki.com/index.php/Email_Injection)
01435         // this is simple but must work
01436         // dodger Task #1532 field "From" in emails from shops
01437         $sFromAdress = substr($sFromAdress, 0, 150);
01438         $sFromName   = substr($sFromName, 0, 150);
01439 
01440         try {
01441             parent::setFrom( $sFromAdress, $sFromName );
01442         } catch( Exception $oEx ) {
01443         }
01444     }
01445 
01451     public function getFrom()
01452     {
01453         return $this->From;
01454     }
01455 
01461     public function getFromName()
01462     {
01463         return $this->FromName;
01464     }
01465 
01474     public function setCharSet( $sCharSet = null )
01475     {
01476         $this->set( "CharSet", $sCharSet ? $sCharSet : oxLang::getInstance()->translateString( "charset" ) );
01477     }
01478 
01484     public function getCharSet()
01485     {
01486         return $this->CharSet;
01487     }
01488 
01496     public function setMailer( $sMailer = null )
01497     {
01498         $this->set( "Mailer", $sMailer );
01499     }
01500 
01506     public function getMailer()
01507     {
01508         return $this->Mailer;
01509     }
01510 
01518     public function setHost( $sHost = null )
01519     {
01520         $this->set( "Host", $sHost );
01521     }
01522 
01528     public function getErrorInfo()
01529     {
01530         return $this->ErrorInfo;
01531     }
01532 
01541     public function setMailWordWrap( $iWordWrap = null )
01542     {
01543         $this->set( "WordWrap", $iWordWrap );
01544     }
01545 
01553     public function setUseInlineImages( $blUseImages = null )
01554     {
01555         $this->_blInlineImgEmail = $blUseImages;
01556     }
01557 
01568     public function addAttachment( $sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01569     {
01570         $sFullPath = $sAttPath . $sAttFile;
01571 
01572         $this->_aAttachments[] = array( $sFullPath, $sAttFile, $sEncoding, $sType );
01573         $blResult = false;
01574 
01575         try {
01576              $blResult = parent::addAttachment( $sFullPath, $sAttFile, $sEncoding, $sType );
01577         } catch( Exception $oEx ) {
01578         }
01579 
01580         return $blResult;
01581     }
01582 
01594     public function addEmbeddedImage( $sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01595     {
01596         $this->_aAttachments[] = array( $sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid );
01597         return parent::addEmbeddedImage( $sFullPath, $sCid, $sAttFile, $sEncoding, $sType );
01598     }
01599 
01605     public function getAttachments()
01606     {
01607         return $this->_aAttachments;
01608     }
01609 
01615     public function clearAttachments()
01616     {
01617         $this->_aAttachments = array();
01618         return parent::clearAttachments();
01619     }
01620 
01630     public function headerLine($sName, $sValue)
01631     {
01632         if (stripos($sName, 'X-') !== false) {
01633             return;
01634         }
01635         return parent::headerLine($sName, $sValue);
01636     }
01637 
01643     protected function _getUseInlineImages()
01644     {
01645         return $this->_blInlineImgEmail;
01646     }
01647 
01653     protected function _sendMailErrorMsg()
01654     {
01655         // build addresses
01656         $sToAdress  = "";
01657         $sToName    = "";
01658 
01659         $aRecipients = $this->getRecipient();
01660 
01661         $sOwnerMessage  = "Error sending eMail(". $this->getSubject().") to: \n\n";
01662 
01663         foreach ( $aRecipients as $aEMail ) {
01664             $sOwnerMessage .= $aEMail[0];
01665             $sOwnerMessage .= ( !empty($aEMail[1]) ) ? ' (' . $aEMail[1] . ')' : '';
01666             $sOwnerMessage .= " \n ";
01667         }
01668         $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01669 
01670         // shop info
01671         $oShop = $this->_getShop();
01672 
01673         $blRet = @mail( $oShop->oxshops__oxorderemail->value, "eMail problem in shop !", $sOwnerMessage);
01674 
01675         return $blRet;
01676     }
01677 
01687     protected function _addUserInfoOrderEMail( $oOrder )
01688     {
01689         return $oOrder;
01690     }
01691 
01701     protected function _addUserRegisterEmail( $oUser )
01702     {
01703         return $oUser;
01704     }
01705 
01715     protected function _addForgotPwdEmail( $oShop )
01716     {
01717         return $oShop;
01718     }
01719 
01729     protected function _addNewsletterDbOptInMail( $oUser )
01730     {
01731         return $oUser;
01732     }
01733 
01739     protected function _clearMailer()
01740     {
01741         $this->clearAllRecipients();
01742         $this->clearReplyTos();
01743         $this->clearAttachments();
01744 
01745         //workaround for phpmailer as it doesn't cleanup as it should
01746         $this->error_count = 0;
01747         $this->ErrorInfo   = '';
01748     }
01749 
01757     protected function _setMailParams( $oShop = null )
01758     {
01759         $this->_clearMailer();
01760 
01761         if ( !$oShop ) {
01762             $oShop = $this->_getShop();
01763         }
01764 
01765         $this->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01766         $this->setSmtp( $oShop );
01767     }
01768 
01777     protected function _getShop( $iLangId = null )
01778     {
01779         $myConfig = $this->getConfig();
01780         if ( $iLangId === null ) {
01781             $iLangId = $myConfig->getActiveShop()->getLanguage();
01782         }
01783         $iLangId = oxLang::getInstance()->validateLanguage( $iLangId );
01784 
01785         if ( !isset( $this->_aShops[$iLangId] ) ) {
01786             $oShop = oxNew( 'oxshop' );
01787             $oShop->loadInLang( $iLangId, $myConfig->getShopId() );
01788             $this->_aShops[$iLangId] = $myConfig->getActiveView()->addGlobalParams( $oShop );
01789         }
01790 
01791         return $this->_aShops[$iLangId];
01792     }
01793 
01802     protected function _setSmtpAuthInfo( $sUserName = null, $sUserPassword = null )
01803     {
01804         $this->set( "SMTPAuth", true );
01805         $this->set( "Username", $sUserName );
01806         $this->set( "Password", $sUserPassword );
01807     }
01808 
01816     protected function _setSmtpDebug( $blDebug = null )
01817     {
01818         $this->set( "SMTPDebug", $blDebug );
01819     }
01820 
01826     protected function _setMailerPluginDir()
01827     {
01828         $this->set( "PluginDir", getShopBasePath() . "core/phpmailer/" );
01829     }
01830 
01837     protected function _makeOutputProcessing()
01838     {
01839         $oOutput = oxNew( "oxoutput" );
01840         $this->setBody( $oOutput->process($this->getBody(), "oxemail") );
01841         $this->setAltBody( $oOutput->process($this->getAltBody(), "oxemail") );
01842         $oOutput->processEmail( $this );
01843     }
01844 
01850     protected function _sendMail()
01851     {
01852         $blResult = false;
01853         try {
01854              $blResult = parent::send();
01855         } catch( Exception $oEx ) {
01856         }
01857 
01858         return $blResult;
01859     }
01860 }

Generated by  doxygen 1.6.2