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 $_sInviteTemplate = "email_invite_html.tpl";
00070
00076 protected $_sInviteTemplatePlain = "email_invite_plain.tpl";
00077
00083 protected $_sSenedNowTemplate = "email_sendednow_html.tpl";
00084
00090 protected $_sSenedNowTemplatePlain = "email_sendednow_plain.tpl";
00091
00097 protected $_sWishListTemplate = "email_wishlist_html.tpl";
00098
00104 protected $_sWishListTemplatePlain = "email_wishlist_plain.tpl";
00105
00111 protected $_sRegisterTemplate = "email_register_html.tpl";
00112
00118 protected $_sRegisterTemplatePlain = "email_register_plain.tpl";
00119
00125 protected $_sReminderMailTemplate = "email_owner_reminder_html.tpl";
00126
00132 protected $_sOrderUserTemplate = "email_order_cust_html.tpl";
00133
00139 protected $_sOrderUserPlainTemplate = "email_order_cust_plain.tpl";
00140
00146 protected $_sOrderOwnerTemplate = "email_order_owner_html.tpl";
00147
00153 protected $_sOrderOwnerPlainTemplate = "email_order_owner_plain.tpl";
00154
00155
00156
00162 protected $_sOrderUserSubjectTemplate = "email_order_cust_subj.tpl";
00163
00169 protected $_sOrderOwnerSubjectTemplate = "email_order_owner_subj.tpl";
00170
00176 protected $_sOwnerPricealarmTemplate = "email_pricealarm_owner.tpl";
00177
00183 protected $_aShops = array();
00184
00190 protected $_blInlineImgEmail = null;
00191
00197 protected $_aRecipients = array();
00198
00204 protected $_aReplies = array();
00205
00211 protected $_aAttachments = array();
00212
00218 protected $_oSmarty = null;
00219
00223 public function __construct()
00224 {
00225
00226 parent::__construct( true );
00227
00228 $myConfig = $this->getConfig();
00229
00230 $this->_setMailerPluginDir();
00231 $this->setSmtp();
00232
00233 $this->setUseInlineImages( $myConfig->getConfigParam('blInlineImgEmail') );
00234 $this->setMailWordWrap( 100 );
00235
00236 $this->isHtml( true );
00237 $this->setLanguage( "en", $myConfig->getConfigParam( 'sShopDir' )."/core/phpmailer/language/");
00238 }
00239
00251 public function __call( $sMethod, $aArgs )
00252 {
00253 if ( defined( 'OXID_PHP_UNIT' ) ) {
00254 if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00255 $sMethod = str_replace( "UNIT", "_", $sMethod );
00256 }
00257 if ( method_exists( $this, $sMethod)) {
00258 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00259 }
00260 }
00261
00262 throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00263 }
00264
00270 public function getConfig()
00271 {
00272 if ( $this->_oConfig == null ) {
00273 $this->_oConfig = oxConfig::getInstance();
00274 }
00275
00276 return $this->_oConfig;
00277 }
00278
00286 public function setConfig( $oConfig )
00287 {
00288 $this->_oConfig = $oConfig;
00289 }
00290
00291
00297 protected function _getSmarty()
00298 {
00299 if ( $this->_oSmarty === null ) {
00300 $this->_oSmarty = oxUtilsView::getInstance()->getSmarty();
00301 }
00302 return $this->_oSmarty;
00303 }
00304
00312 public function send()
00313 {
00314
00315 if ( count( $this->getRecipient() ) < 1 ) {
00316 return false;
00317 }
00318
00319 $myConfig = $this->getConfig();
00320 $this->setCharSet();
00321
00322 if ( $this->_getUseInlineImages() ) {
00323 $this->_includeImages( $myConfig->getImageDir(), $myConfig->getNoSSLImageDir( isAdmin() ), $myConfig->getDynImageDir(),
00324 $myConfig->getAbsImageDir(), $myConfig->getAbsDynImageDir());
00325 }
00326
00327 $this->_makeOutputProcessing();
00328
00329
00330 if ( $this->getMailer() == 'smtp' ) {
00331 $blRet = $this->_sendMail();
00332
00333
00334 if ( !$blRet ) {
00335 $this->setMailer( 'mail' );
00336 $blRet = $this->_sendMail();
00337 }
00338 } else {
00339
00340 $this->setMailer( 'mail' );
00341 $blRet = $this->_sendMail();
00342 }
00343
00344 if ( !$blRet ) {
00345
00346 $this->_sendMailErrorMsg();
00347 }
00348
00349 return $blRet;
00350 }
00351
00360 protected function _setSmtpProtocol($sUrl)
00361 {
00362 $sProtocol = '';
00363 $sSmtpHost = $sUrl;
00364 if ( getStr()->preg_match('@^([0-9a-z]+://)?(.*)$@i', $sUrl, $m ) ) {
00365 if ($m[1]) {
00366 if (($m[1] == 'ssl://') || ($m[1] == 'tls://')) {
00367 $this->set( "SMTPSecure", substr($m[1], 0, 3) );
00368 } else {
00369 $sProtocol = $m[1];
00370 }
00371 }
00372 $sSmtpHost = $m[2];
00373 }
00374
00375 return $sProtocol.$sSmtpHost;
00376 }
00377
00385 public function setSmtp( $oShop = null )
00386 {
00387 $myConfig = $this->getConfig();
00388 $oShop = ( $oShop ) ? $oShop : $this->_getShop();
00389
00390 $sSmtpUrl = $this->_setSmtpProtocol($oShop->oxshops__oxsmtp->value);
00391
00392 if ( !$this->_isValidSmtpHost( $sSmtpUrl ) ) {
00393 $this->setMailer( "mail" );
00394 return;
00395 }
00396
00397 $this->setHost( $sSmtpUrl );
00398 $this->setMailer( "smtp" );
00399
00400 if ( $oShop->oxshops__oxsmtpuser->value ) {
00401 $this->_setSmtpAuthInfo( $oShop->oxshops__oxsmtpuser->value, $oShop->oxshops__oxsmtppwd->value );
00402 }
00403
00404 if ( $myConfig->getConfigParam( 'iDebug' ) == 6 ) {
00405 $this->_setSmtpDebug( true );
00406 }
00407 }
00408
00416 protected function _isValidSmtpHost( $sSmtpHost )
00417 {
00418 $blIsSmtp = false;
00419 if ( $sSmtpHost ) {
00420 $sSmtpPort = $this->SMTP_PORT;
00421 if ( getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $sSmtpHost, $m)) {
00422 $sSmtpHost = $m[1];
00423 $sSmtpPort = (int)$m[3];
00424 if (!$sSmtpPort) {
00425 $sSmtpPort = $this->SMTP_PORT;
00426 }
00427 }
00428 if ( $blIsSmtp = (bool) ( $rHandle = @fsockopen( $sSmtpHost, $sSmtpPort, $iErrNo, $sErrStr, 30 )) ) {
00429
00430 fclose( $rHandle );
00431 }
00432 }
00433
00434 return $blIsSmtp;
00435 }
00436
00446 public function sendOrderEmailToUser( $oOrder, $sSubject = null )
00447 {
00448 $myConfig = $this->getConfig();
00449
00450
00451 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00452
00453
00454 $oShop = $this->_getShop();
00455 $this->_setMailParams( $oShop );
00456
00457
00458
00459 $oOrder->oDelSet = $oOrder->getDelSet();
00460
00461 $oUser = $oOrder->getOrderUser();
00462
00463 $oSmarty = $this->_getSmarty();
00464 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00465 $oSmarty->assign( "order", $oOrder);
00466 $oSmarty->assign( "shop", $oShop );
00467 $oSmarty->assign( "oViewConf", $oShop );
00468 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00469 $oSmarty->assign( "user", $oUser );
00470 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00471 $oSmarty->assign( "basket", $oOrder->getBasket() );
00472 $oSmarty->assign( "payment", $oOrder->getPayment() );
00473 if ( $oUser ) {
00474 $oSmarty->assign( "reviewuserhash", $oUser->getReviewUserHash( $oUser->getId() ) );
00475 }
00476 $oSmarty->assign( "paymentinfo", $myConfig->getActiveShop() );
00477
00478
00479 $oSmarty->assign( "iswishlist", true );
00480 $oSmarty->assign( "isreview", true );
00481
00482 if ( $aVoucherList = $oOrder->getVoucherList() ) {
00483 $oSmarty->assign( "vouchers", $aVoucherList );
00484 }
00485
00486 $oOutputProcessor = oxNew( "oxoutput" );
00487 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00488
00489 foreach ( $aNewSmartyArray as $key => $val ) {
00490 $oSmarty->assign( $key, $val );
00491 }
00492
00493 $this->setBody( $oSmarty->fetch( $this->_sOrderUserTemplate ) );
00494 $this->setAltBody( $oSmarty->fetch( $this->_sOrderUserPlainTemplate ) );
00495
00496
00497 if ( $sSubject === null ) {
00498 if ( $oSmarty->template_exists( $this->_sOrderUserSubjectTemplate) ) {
00499 $sSubject = $oSmarty->fetch( $this->_sOrderUserSubjectTemplate );
00500 } else {
00501 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00502 }
00503 }
00504
00505 $this->setSubject( $sSubject );
00506
00507 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00508
00509 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00510 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00511
00512 $blSuccess = $this->send();
00513
00514 return $blSuccess;
00515 }
00516
00526 public function sendOrderEmailToOwner( $oOrder, $sSubject = null )
00527 {
00528 $myConfig = $this->getConfig();
00529
00530 $oShop = $this->_getShop();
00531
00532
00533 $this->_clearMailer();
00534
00535
00536 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00537
00538
00539 $sFullName = $oOrder->getOrderUser()->oxuser__oxfname->getRawValue() . " " . $oOrder->getOrderUser()->oxuser__oxlname->getRawValue();
00540 $this->setFrom( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00541
00542 $oLang = oxLang::getInstance();
00543 $iOrderLang = $oLang->getObjectTplLanguage();
00544
00545
00546
00547 if ( $oShop->getLanguage() != $iOrderLang ) {
00548 $oShop = $this->_getShop( $iOrderLang );
00549 }
00550
00551 $this->setSmtp( $oShop );
00552
00553
00554 $oSmarty = $this->_getSmarty();
00555 $oSmarty->assign( "charset", $oLang->translateString("charset"));
00556 $oSmarty->assign( "order", $oOrder );
00557 $oSmarty->assign( "shop", $oShop );
00558 $oSmarty->assign( "oViewConf", $oShop );
00559 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00560 $oSmarty->assign( "user", $oOrder->getOrderUser() );
00561 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00562 $oSmarty->assign( "basket", $oOrder->getBasket() );
00563 $oSmarty->assign( "payment", $oOrder->getPayment() );
00564
00565
00566 $oSmarty->assign( "iswishlist", true);
00567
00568 if( $oOrder->getVoucherList() )
00569 $oSmarty->assign( "vouchers", $oOrder->getVoucherList() );
00570
00571 $oOutputProcessor = oxNew( "oxoutput" );
00572 $aNewSmartyArray = $oOutputProcessor->processViewArray($oSmarty->get_template_vars(), "oxemail");
00573 foreach ($aNewSmartyArray as $key => $val)
00574 $oSmarty->assign( $key, $val );
00575
00576 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerTemplate, false ) ) );
00577 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerPlainTemplate, false ) ) );
00578
00579
00580
00581 if ( $sSubject === null ) {
00582 if ( $oSmarty->template_exists( $this->_sOrderOwnerSubjectTemplate) ) {
00583 $sSubject = $oSmarty->fetch( $this->_sOrderOwnerSubjectTemplate );
00584 } else {
00585 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00586 }
00587 }
00588
00589 $this->setSubject( $sSubject );
00590 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oLang->translateString("order") );
00591
00592 if ( $oOrder->getOrderUser()->oxuser__oxusername->value != "admin" )
00593 $this->setReplyTo( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00594
00595 $blSuccess = $this->send();
00596
00597
00598 $oRemark = oxNew( "oxremark" );
00599 $oRemark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
00600 $oRemark->oxremark__oxparentid = new oxField($oOrder->getOrderUser()->getId(), oxField::T_RAW);
00601 $oRemark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
00602 $oRemark->save();
00603
00604
00605 if ( $myConfig->getConfigParam( 'iDebug' ) == 6) {
00606 oxUtils::getInstance()->showMessageAndExit( "" );
00607 }
00608
00609 return $blSuccess;
00610 }
00611
00621 public function sendRegisterConfirmEmail( $oUser, $sSubject = null )
00622 {
00623
00624 $oSmarty = $this->_getSmarty();
00625 $oSmarty->assign( "contentident", "oxregisteraltemail" );
00626 $oSmarty->assign( "contentplainident", "oxregisterplainaltemail" );
00627
00628
00629 return $this->sendRegisterEmail( $oUser, $sSubject );
00630 }
00631
00641 public function sendRegisterEmail( $oUser, $sSubject = null )
00642 {
00643
00644 $oUser = $this->_addUserRegisterEmail( $oUser );
00645
00646
00647 $oShop = $this->_getShop();
00648
00649
00650 $this->_setMailParams( $oShop );
00651
00652
00653 $oSmarty = $this->_getSmarty();
00654 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00655 $oSmarty->assign( "shop", $oShop );
00656 $oSmarty->assign( "oViewConf", $oShop );
00657 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00658 $oSmarty->assign( "user", $oUser );
00659
00660 $oOutputProcessor = oxNew( "oxoutput" );
00661 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00662
00663 foreach ( $aNewSmartyArray as $key => $val ) {
00664 $oSmarty->assign( $key, $val );
00665 }
00666
00667 $this->setBody( $oSmarty->fetch( $this->_sRegisterTemplate ) );
00668 $this->setAltBody( $oSmarty->fetch( $this->_sRegisterTemplatePlain ) );
00669
00670 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue() );
00671
00672 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00673
00674 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00675 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00676
00677 return $this->send();
00678 }
00679
00689 public function sendForgotPwdEmail( $sEmailAddress, $sSubject = null )
00690 {
00691 $myConfig = $this->getConfig();
00692 $oDb = oxDb::getDb();
00693
00694
00695 $oShop = $this->_getShop();
00696
00697
00698 $oShop = $this->_addForgotPwdEmail( $oShop);
00699
00700
00701 $this->_setMailParams( $oShop );
00702
00703
00704 $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sEmailAddress )." and oxuser.oxpassword != ''";
00705 $sOrder = "";
00706 if ( $myConfig->getConfigParam( 'blMallUsers' )) {
00707 $sOrder = "order by oxshopid = '".$oShop->getId()."' desc";
00708 } else {
00709 $sWhere .= " and oxshopid = '".$oShop->getId()."'";
00710 }
00711
00712 $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00713 if ( ( $sOxId = $oDb->getOne( $sSelect ) ) ) {
00714
00715 $oUser = oxNew( 'oxuser' );
00716 if ( $oUser->load($sOxId) ) {
00717
00718 $oSmarty = $this->_getSmarty();
00719 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00720 $oSmarty->assign( "shop", $oShop );
00721 $oSmarty->assign( "oViewConf", $oShop );
00722 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00723 $oSmarty->assign( "user", $oUser );
00724
00725 $oOutputProcessor = oxNew( "oxoutput" );
00726 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00727
00728 foreach ( $aNewSmartyArray as $key => $val ) {
00729 $oSmarty->assign($key, $val);
00730 }
00731
00732 $this->setBody( $oSmarty->fetch( $this->_sForgotPwdTemplate ) );
00733 $this->setAltBody( $oSmarty->fetch( $this->_sForgotPwdTemplatePlain ) );
00734
00735
00736 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue() );
00737
00738 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00739
00740 $this->setRecipient( $sEmailAddress, $sFullName );
00741 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00742
00743 return $this->send();
00744 }
00745 }
00746
00747 return false;
00748 }
00749
00760 public function sendContactMail( $sEmailAddress = null, $sSubject = null, $sMessage = null )
00761 {
00762
00763
00764 $oShop = $this->_getShop();
00765
00766
00767 $this->_setMailParams( $oShop );
00768
00769 $this->setBody( $sMessage );
00770 $this->setSubject( $sSubject );
00771
00772 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00773 $this->setFrom( $sEmailAddress, "" );
00774 $this->setReplyTo( $sEmailAddress, "" );
00775
00776 return $this->send();
00777 }
00778
00788 public function sendNewsletterDbOptInMail( $oUser, $sSubject = null )
00789 {
00790 $oLang = oxLang::getInstance();
00791
00792
00793 $oUser = $this->_addNewsletterDbOptInMail( $oUser );
00794
00795
00796 $oShop = $this->_getShop();
00797
00798
00799 $this->_setMailParams( $oShop );
00800
00801
00802 $oSmarty = $this->_getSmarty();
00803 $oSmarty->assign( "charset", $oLang->translateString("charset"));
00804 $oSmarty->assign( "shop", $oShop );
00805 $oSmarty->assign( "oViewConf", $oShop );
00806 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00807 $oSmarty->assign( "subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value) );
00808 $oSmarty->assign( "user", $oUser );
00809
00810 $oOutputProcessor = oxNew( "oxoutput" );
00811 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00812 foreach ( $aNewSmartyArray as $key => $val ) {
00813 $oSmarty->assign( $key, $val );
00814 }
00815
00816 $this->setBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplate ) );
00817 $this->setAltBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplatePlain ) );
00818 $this->setSubject( ( $sSubject !== null ) ? $sSubject : oxLang::getInstance()->translateString("EMAIL_NEWSLETTERDBOPTINMAIL_SUBJECT") . " " . $oShop->oxshops__oxname->getRawValue() );
00819
00820 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00821
00822 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00823 $this->setFrom( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00824 $this->setReplyTo( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00825
00826 return $this->send();
00827 }
00828
00836 protected function _getNewsSubsLink( $sId )
00837 {
00838 $myConfig = $this->getConfig();
00839 $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00840
00841 $sUrl = $myConfig->getShopHomeURL().'cl=newsletter&fnc=addme&uid='.$sId.$sLang;
00842 $sUrl .= ( $iActShopLang ) ? '&lang='.$iActShopLang : "";
00843 return $sUrl;
00844 }
00845
00856 public function sendNewsletterMail( $oNewsLetter, $oUser, $sSubject = null )
00857 {
00858
00859 $oShop = $this->_getShop();
00860
00861
00862 $this->_setMailParams( $oShop );
00863
00864 $sBody = $oNewsLetter->getHtmlText();
00865
00866 if ( !empty($sBody) ) {
00867 $this->setBody( $sBody );
00868 $this->setAltBody( $oNewsLetter->getPlainText() );
00869 } else {
00870 $this->isHtml( false );
00871 $this->setBody( $oNewsLetter->getPlainText() );
00872 }
00873
00874 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue() );
00875
00876 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00877 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00878 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00879
00880 return $this->send();
00881 }
00882
00892 public function sendSuggestMail( $oParams, $oProduct )
00893 {
00894 $myConfig = $this->getConfig();
00895
00896
00897 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00898
00899
00900 $oShop = $this->_getShop( $iCurrLang );
00901
00902
00903 if ( $oProduct->getLanguage() != $iCurrLang ) {
00904 $oProduct->setLanguage( $iCurrLang );
00905 $oProduct->load( $oProduct->getId() );
00906 }
00907
00908
00909 $this->setFrom( $oParams->send_email, $oParams->send_name );
00910 $this->setSMTP();
00911
00912
00913 $oSmarty = $this->_getSmarty();
00914 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00915 $oSmarty->assign( "shop", $oShop );
00916 $oSmarty->assign( "oViewConf", $oShop );
00917 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00918 $oSmarty->assign( "userinfo", $oParams );
00919 $oSmarty->assign( "product", $oProduct );
00920
00921 $sArticleUrl = $oProduct->getLink();
00922
00923
00924 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00925 $sArticleUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sArticleUrl );
00926 $sArticleUrl .= "su=" . $oActiveUser->getId();
00927 }
00928
00929 $oSmarty->assign( "sArticleUrl", $sArticleUrl );
00930
00931 $oOutputProcessor = oxNew( "oxoutput" );
00932 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00933
00934 foreach ( $aNewSmartyArray as $key => $val ) {
00935 $oSmarty->assign( $key, $val );
00936 }
00937
00938 $this->setBody( $oSmarty->fetch( $this->_sSuggestTemplate ) );
00939 $this->setAltBody( $oSmarty->fetch( $this->_sSuggestTemplatePlain ) );
00940 $this->setSubject( $oParams->send_subject );
00941
00942 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
00943 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00944
00945 return $this->send();
00946 }
00947
00956 public function sendInviteMail( $oParams )
00957 {
00958 $myConfig = $this->getConfig();
00959
00960
00961 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00962
00963
00964 $oShop = $this->_getShop( $iCurrLang );
00965
00966
00967 $this->setFrom( $oParams->send_email, $oParams->send_name );
00968 $this->setSMTP();
00969
00970
00971 $oSmarty = oxUtilsView::getInstance()->getSmarty();
00972 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00973 $oSmarty->assign( "shop", $oShop );
00974 $oSmarty->assign( "oViewConf", $oShop );
00975 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00976 $oSmarty->assign( "userinfo", $oParams );
00977 $oSmarty->assign( "sShopUrl", $myConfig->getShopCurrentUrl() );
00978
00979 $sHomeUrl = $oShop->getHomeLink();
00980
00981
00982 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00983 $sHomeUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sHomeUrl );
00984 $sHomeUrl .= "su=" . $oActiveUser->getId();
00985 }
00986
00987 $oSmarty->assign( "sHomeUrl", $sHomeUrl );
00988
00989 $oOutputProcessor = oxNew( "oxoutput" );
00990 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00991
00992 foreach ( $aNewSmartyArray as $key => $val ) {
00993 $oSmarty->assign( $key, $val );
00994 }
00995
00996 $this->setBody( $oSmarty->fetch( $this->_sInviteTemplate ) );
00997
00998 $this->setAltBody( $oSmarty->fetch( $this->_sInviteTemplatePlain ) );
00999 $this->setSubject( $oParams->send_subject );
01000
01001 if ( is_array($oParams->rec_email) && count($oParams->rec_email) > 0 ) {
01002 foreach ( $oParams->rec_email as $sEmail ) {
01003 if ( !empty( $sEmail ) ) {
01004 $this->setRecipient( $sEmail );
01005 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01006 $this->send();
01007 $this->clearAllRecipients();
01008 }
01009 }
01010
01011 return true;
01012 }
01013
01014 return false;
01015 }
01016
01026 public function sendSendedNowMail( $oOrder, $sSubject = null )
01027 {
01028 $myConfig = $this->getConfig();
01029
01030 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01031
01032
01033 $oShop = $this->_getShop( $iOrderLang );
01034
01035
01036 $this->_setMailParams( $oShop );
01037
01038
01039
01040
01041
01042 $oLang = oxLang::getInstance();
01043 $oSmarty = $this->_getSmarty();
01044 $oSmarty->assign( "charset", $oLang->translateString("charset"));
01045 $oSmarty->assign( "shop", $oShop );
01046 $oSmarty->assign( "oViewConf", $oShop );
01047 $oSmarty->assign( "oView", $myConfig->getActiveView() );
01048 $oSmarty->assign( "order", $oOrder );
01049 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
01050
01051
01052 $oSmarty->assign( "isreview", true);
01053 $oUser = oxNew( 'oxuser' );
01054 $oSmarty->assign( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01055
01056 $oOutputProcessor = oxNew( "oxoutput" );
01057 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
01058
01059 foreach ( $aNewSmartyArray as $key => $val ) {
01060 $oSmarty->assign( $key, $val );
01061 }
01062
01063
01064 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01065
01066 $iOldTplLang = $oLang->getTplLanguage();
01067 $iOldBaseLang = $oLang->getTplLanguage();
01068 $oLang->setTplLanguage( $iOrderLang );
01069 $oLang->setBaseLanguage( $iOrderLang );
01070
01071 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01072
01073 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplate, false ) ) );
01074 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplatePlain, false ) ) );
01075 $oLang->setTplLanguage( $iOldTplLang );
01076 $oLang->setBaseLanguage( $iOldBaseLang );
01077
01078 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01079
01080
01081 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue() );
01082
01083 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01084
01085 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01086 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01087 return $this->send();
01088 }
01089
01104 public function sendBackupMail( $aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError )
01105 {
01106
01107
01108
01109
01110
01111
01112
01113 $oShop = $this->_getShop();
01114
01115
01116 $this->_setMailParams( $oShop );
01117
01118 $this->setBody( $sMessage );
01119 $this->setSubject( $sSubject );
01120
01121 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
01122 $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
01123
01124 $this->setFrom( $sEmailAddress, "" );
01125 $this->setReplyTo( $sEmailAddress, "" );
01126
01127
01128 $blAttashSucc = true;
01129 $sAttPath = oxUtilsFile::getInstance()->normalizeDir($sAttPath);
01130 foreach ( $aAttFiles as $iNum => $sAttFile ) {
01131 if ( file_exists($sAttPath . $sAttFile) && is_file($sAttPath . $sAttFile) ) {
01132 $blAttashSucc = $this->addAttachment( $sAttPath, $sAttFile );
01133 } else {
01134 $blAttashSucc = false;
01135 $aError[] = array( 5, $sAttFile );
01136 }
01137 }
01138
01139 if ( !$blAttashSucc ) {
01140 $aError[] = array( 4, "" );
01141 $this->clearAttachments();
01142 return false;
01143 }
01144
01145 $aStatus[] = 3;
01146 $blSend = $this->send();
01147 $this->clearAttachments();
01148
01149 return $blSend;
01150 }
01151
01162 public function sendEmail( $sTo, $sSubject, $sBody )
01163 {
01164
01165 $this->_setMailParams();
01166
01167 if ( is_array($sTo) ) {
01168 foreach ($sTo as $sAddress) {
01169 $this->setRecipient( $sAddress, "" );
01170 $this->setReplyTo( $sAddress, "" );
01171 }
01172 } else {
01173 $this->setRecipient( $sTo, "" );
01174 $this->setReplyTo( $sTo, "" );
01175 }
01176
01177
01178 $this->isHtml( false );
01179
01180 $this->setSubject( $sSubject );
01181 $this->setBody( $sBody );
01182
01183 return $this->send();
01184 }
01185
01194 public function sendStockReminder( $aBasketContents, $sSubject = null )
01195 {
01196 $blSend = false;
01197
01198 $oArticleList = oxNew( "oxarticlelist" );
01199 $oArticleList->loadStockRemindProducts( $aBasketContents );
01200
01201
01202 if ( $oArticleList->count() ) {
01203 $oShop = $this->_getShop();
01204
01205
01206 $this->_setMailParams( $oShop );
01207 $oLang = oxLang::getInstance();
01208
01209 $oSmarty = $this->_getSmarty();
01210 $oSmarty->assign( "charset", $oLang->translateString( "charset" ) );
01211 $oSmarty->assign( "shop", $oShop );
01212 $oSmarty->assign( "oViewConf", $oShop );
01213 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01214 $oSmarty->assign( "articles", $oArticleList );
01215
01216 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01217 $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01218 $this->setBody( $oSmarty->fetch( $this->getConfig()->getTemplatePath( $this->_sReminderMailTemplate, false ) ) );
01219 $this->setAltBody( "" );
01220 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_STOCKREMINDER_SUBJECT' ) );
01221
01222 $blSend = $this->send();
01223 }
01224
01225 return $blSend;
01226 }
01227
01236 public function sendWishlistMail( $oParams )
01237 {
01238 $myConfig = $this->getConfig();
01239
01240 $this->_clearMailer();
01241
01242
01243 $oShop = $this->_getShop();
01244
01245
01246 $this->setFrom( $oParams->send_email, $oParams->send_name );
01247 $this->setSMTP();
01248
01249
01250 $oSmarty = $this->_getSmarty();
01251 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
01252 $oSmarty->assign( "shop", $oShop );
01253 $oSmarty->assign( "oViewConf", $oShop );
01254 $oSmarty->assign( "oView", $myConfig->getActiveView() );
01255 $oSmarty->assign( "userinfo", $oParams );
01256
01257 $this->setBody( $oSmarty->fetch( $this->_sWishListTemplate ) );
01258 $this->setAltBody( $oSmarty->fetch( $this->_sWishListTemplatePlain ) );
01259 $this->setSubject( $oParams->send_subject );
01260
01261 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
01262 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01263
01264 return $this->send();
01265 }
01266
01277 public function sendPriceAlarmNotification( $aParams, $oAlarm, $sSubject = null )
01278 {
01279 $this->_clearMailer();
01280 $oShop = $this->_getShop();
01281
01282
01283 $this->_setMailParams( $oShop );
01284
01285 $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01286
01287 $oArticle = oxNew( "oxarticle" );
01288 $oArticle->setSkipAbPrice( true );
01289 $oArticle->loadInLang( $iAlarmLang, $aParams['aid'] );
01290
01291 $oCur = $this->getConfig()->getActShopCurrencyObject();
01292 $oLang = oxLang::getInstance();
01293
01294
01295 $oSmarty = $this->_getSmarty();
01296 $oSmarty->assign( "shop", $oShop );
01297 $oSmarty->assign( "oViewConf", $oShop );
01298 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01299 $oSmarty->assign( "product", $oArticle );
01300 $oSmarty->assign( "email", $aParams['email']);
01301 $oSmarty->assign( "bidprice", $oLang->formatCurrency( $oAlarm->oxpricealarm__oxprice->value, $oCur ) );
01302 $oSmarty->assign( "currency", $oCur );
01303
01304 $this->setRecipient( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01305 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_PRICEALARM_OWNER_SUBJECT', $iAlarmLang ) . " " . $oArticle->oxarticles__oxtitle->getRawValue() );
01306 $this->setBody( $oSmarty->fetch( $this->_sOwnerPricealarmTemplate ) );
01307 $this->setFrom( $aParams['email'], "" );
01308 $this->setReplyTo( $aParams['email'], "" );
01309
01310 return $this->send();
01311 }
01312
01324 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01325 {
01326 $sBody = $this->getBody();
01327 if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01328
01329 $oFileUtils = oxUtilsFile::getInstance();
01330 $blReSetBody = false;
01331
01332
01333 $sDynImageDir = $oFileUtils->normalizeDir( $sDynImageDir );
01334 $sImageDir = $oFileUtils->normalizeDir( $sImageDir );
01335 $sImageDirNoSSL = $oFileUtils->normalizeDir( $sImageDirNoSSL );
01336
01337 if (is_array($matches) && count($matches)) {
01338 $aImageCache = array();
01339 $myUtils = oxUtils::getInstance();
01340 $myUtilsObject = oxUtilsObject::getInstance();
01341
01342 foreach ($matches as $aImage) {
01343
01344 $image = $aImage[1];
01345 $sFileName = '';
01346 if ( strpos( $image, $sDynImageDir ) === 0 ) {
01347 $sFileName = $oFileUtils->normalizeDir( $sAbsDynImageDir ) . str_replace( $sDynImageDir, '', $image );
01348 } elseif ( strpos( $image, $sImageDir ) === 0 ) {
01349 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDir, '', $image );
01350 } elseif ( strpos( $image, $sImageDirNoSSL ) === 0 ) {
01351 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDirNoSSL, '', $image );
01352 }
01353
01354 if ($sFileName && @is_file($sFileName)) {
01355 $sCId = '';
01356 if ( isset( $aImageCache[$sFileName] ) && $aImageCache[$sFileName] ) {
01357 $sCId = $aImageCache[$sFileName];
01358 } else {
01359 $sCId = $myUtilsObject->generateUID();
01360 $sMIME = $myUtils->oxMimeContentType($sFileName);
01361 if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01362 if ( $this->addEmbeddedImage( $sFileName, $sCId, "image", "base64", $sMIME ) ) {
01363 $aImageCache[$sFileName] = $sCId;
01364 } else {
01365 $sCId = '';
01366 }
01367 }
01368 }
01369 if ( $sCId && $sCId == $aImageCache[$sFileName] ) {
01370 if ( $sReplTag = str_replace( $image, 'cid:'.$sCId, $aImage[0] ) ) {
01371 $sBody = str_replace($aImage[0], $sReplTag, $sBody );
01372 $blReSetBody = true;
01373 }
01374 }
01375 }
01376 }
01377 }
01378
01379 if ( $blReSetBody ) {
01380 $this->setBody( $sBody );
01381 }
01382 }
01383 }
01384
01392 public function setSubject( $sSubject = null )
01393 {
01394
01395 $sSubject = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sSubject);
01396
01397 $this->set( "Subject", $sSubject );
01398 }
01399
01405 public function getSubject()
01406 {
01407 return $this->Subject;
01408 }
01409
01419 public function setBody( $sBody = null, $blClearSid = true )
01420 {
01421 if ( $blClearSid ) {
01422 $sBody = getStr()->preg_replace("/sid=[A-Z0-9\.]+/i", "sid=x&shp=" . $this->getConfig()->getShopId(), $sBody);
01423 }
01424
01425 $this->set( "Body", $sBody );
01426 }
01427
01433 public function getBody()
01434 {
01435 return $this->Body;
01436 }
01437
01447 public function setAltBody( $sAltBody = null, $blClearSid = true )
01448 {
01449 if ( $blClearSid ) {
01450 $sAltBody = getStr()->preg_replace("/sid=[A-Z0-9\.]+/i", "sid=x&shp=" . $this->getConfig()->getShopId(), $sAltBody);
01451 }
01452
01453
01454 $sAltBody = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sAltBody);
01455
01456 $this->set( "AltBody", $sAltBody );
01457 }
01458
01464 public function getAltBody()
01465 {
01466 return $this->AltBody;
01467 }
01468
01477 public function setRecipient( $sAddress = null, $sName = null )
01478 {
01479 try {
01480 parent::AddAddress( $sAddress, $sName );
01481
01482
01483 $this->_aRecipients[] = array( $sAddress, $sName );
01484 } catch( Exception $oEx ) {
01485 }
01486 }
01487
01495 public function getRecipient()
01496 {
01497 return $this->_aRecipients;
01498 }
01499
01506 public function clearAllRecipients()
01507 {
01508 $this->_aRecipients = array();
01509 parent::clearAllRecipients();
01510 }
01511
01523 public function setReplyTo( $sEmail = null, $sName = null )
01524 {
01525 if ( !oxUtils::getInstance()->isValidEmail( $sEmail ) ) {
01526 $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01527 }
01528
01529 $this->_aReplies[] = array( $sEmail, $sName );
01530
01531 try {
01532 parent::addReplyTo( $sEmail, $sName );
01533 } catch( Exception $oEx ) {
01534 }
01535 }
01536
01542 public function getReplyTo()
01543 {
01544 return $this->_aReplies;
01545 }
01546
01552 public function clearReplyTos()
01553 {
01554 $this->_aReplies = array();
01555 parent::clearReplyTos();
01556 }
01557
01566 public function setFrom( $sFromAdress, $sFromName = null )
01567 {
01568
01569
01570
01571 $sFromAdress = substr($sFromAdress, 0, 150);
01572 $sFromName = substr($sFromName, 0, 150);
01573
01574 try {
01575 parent::setFrom( $sFromAdress, $sFromName );
01576 } catch( Exception $oEx ) {
01577 }
01578 }
01579
01585 public function getFrom()
01586 {
01587 return $this->From;
01588 }
01589
01595 public function getFromName()
01596 {
01597 return $this->FromName;
01598 }
01599
01608 public function setCharSet( $sCharSet = null )
01609 {
01610 $this->set( "CharSet", $sCharSet ? $sCharSet : oxLang::getInstance()->translateString( "charset" ) );
01611 }
01612
01618 public function getCharSet()
01619 {
01620 return $this->CharSet;
01621 }
01622
01630 public function setMailer( $sMailer = null )
01631 {
01632 $this->set( "Mailer", $sMailer );
01633 }
01634
01640 public function getMailer()
01641 {
01642 return $this->Mailer;
01643 }
01644
01652 public function setHost( $sHost = null )
01653 {
01654 $this->set( "Host", $sHost );
01655 }
01656
01662 public function getErrorInfo()
01663 {
01664 return $this->ErrorInfo;
01665 }
01666
01675 public function setMailWordWrap( $iWordWrap = null )
01676 {
01677 $this->set( "WordWrap", $iWordWrap );
01678 }
01679
01687 public function setUseInlineImages( $blUseImages = null )
01688 {
01689 $this->_blInlineImgEmail = $blUseImages;
01690 }
01691
01702 public function addAttachment( $sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01703 {
01704 $sFullPath = $sAttPath . $sAttFile;
01705
01706 $this->_aAttachments[] = array( $sFullPath, $sAttFile, $sEncoding, $sType );
01707 $blResult = false;
01708
01709 try {
01710 $blResult = parent::addAttachment( $sFullPath, $sAttFile, $sEncoding, $sType );
01711 } catch( Exception $oEx ) {
01712 }
01713
01714 return $blResult;
01715 }
01716
01728 public function addEmbeddedImage( $sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01729 {
01730 $this->_aAttachments[] = array( $sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid );
01731 return parent::addEmbeddedImage( $sFullPath, $sCid, $sAttFile, $sEncoding, $sType );
01732 }
01733
01739 public function getAttachments()
01740 {
01741 return $this->_aAttachments;
01742 }
01743
01749 public function clearAttachments()
01750 {
01751 $this->_aAttachments = array();
01752 return parent::clearAttachments();
01753 }
01754
01764 public function headerLine($sName, $sValue)
01765 {
01766 if (stripos($sName, 'X-') !== false) {
01767 return;
01768 }
01769 return parent::headerLine($sName, $sValue);
01770 }
01771
01777 protected function _getUseInlineImages()
01778 {
01779 return $this->_blInlineImgEmail;
01780 }
01781
01787 protected function _sendMailErrorMsg()
01788 {
01789
01790 $sToAdress = "";
01791 $sToName = "";
01792
01793 $aRecipients = $this->getRecipient();
01794
01795 $sOwnerMessage = "Error sending eMail(". $this->getSubject().") to: \n\n";
01796
01797 foreach ( $aRecipients as $aEMail ) {
01798 $sOwnerMessage .= $aEMail[0];
01799 $sOwnerMessage .= ( !empty($aEMail[1]) ) ? ' (' . $aEMail[1] . ')' : '';
01800 $sOwnerMessage .= " \n ";
01801 }
01802 $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01803
01804
01805 $oShop = $this->_getShop();
01806
01807 $blRet = @mail( $oShop->oxshops__oxorderemail->value, "eMail problem in shop !", $sOwnerMessage);
01808
01809 return $blRet;
01810 }
01811
01821 protected function _addUserInfoOrderEMail( $oOrder )
01822 {
01823 return $oOrder;
01824 }
01825
01835 protected function _addUserRegisterEmail( $oUser )
01836 {
01837 return $oUser;
01838 }
01839
01849 protected function _addForgotPwdEmail( $oShop )
01850 {
01851 return $oShop;
01852 }
01853
01863 protected function _addNewsletterDbOptInMail( $oUser )
01864 {
01865 return $oUser;
01866 }
01867
01873 protected function _clearMailer()
01874 {
01875 $this->clearAllRecipients();
01876 $this->clearReplyTos();
01877 $this->clearAttachments();
01878
01879
01880 $this->error_count = 0;
01881 $this->ErrorInfo = '';
01882 }
01883
01891 protected function _setMailParams( $oShop = null )
01892 {
01893 $this->_clearMailer();
01894
01895 if ( !$oShop ) {
01896 $oShop = $this->_getShop();
01897 }
01898
01899 $this->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01900 $this->setSmtp( $oShop );
01901 }
01902
01911 protected function _getShop( $iLangId = null )
01912 {
01913 $myConfig = $this->getConfig();
01914 if ( $iLangId === null ) {
01915 $iLangId = $myConfig->getActiveShop()->getLanguage();
01916 }
01917 $iLangId = oxLang::getInstance()->validateLanguage( $iLangId );
01918
01919 if ( !isset( $this->_aShops[$iLangId] ) ) {
01920 $oShop = oxNew( 'oxshop' );
01921 $oShop->loadInLang( $iLangId, $myConfig->getShopId() );
01922 $this->_aShops[$iLangId] = $myConfig->getActiveView()->addGlobalParams( $oShop );
01923 }
01924
01925 return $this->_aShops[$iLangId];
01926 }
01927
01936 protected function _setSmtpAuthInfo( $sUserName = null, $sUserPassword = null )
01937 {
01938 $this->set( "SMTPAuth", true );
01939 $this->set( "Username", $sUserName );
01940 $this->set( "Password", $sUserPassword );
01941 }
01942
01950 protected function _setSmtpDebug( $blDebug = null )
01951 {
01952 $this->set( "SMTPDebug", $blDebug );
01953 }
01954
01960 protected function _setMailerPluginDir()
01961 {
01962 $this->set( "PluginDir", getShopBasePath() . "core/phpmailer/" );
01963 }
01964
01971 protected function _makeOutputProcessing()
01972 {
01973 $oOutput = oxNew( "oxoutput" );
01974 $this->setBody( $oOutput->process($this->getBody(), "oxemail") );
01975 $this->setAltBody( $oOutput->process($this->getAltBody(), "oxemail") );
01976 $oOutput->processEmail( $this );
01977 }
01978
01984 protected function _sendMail()
01985 {
01986 $blResult = false;
01987 try {
01988 $blResult = parent::send();
01989 } catch( Exception $oEx ) {
01990 }
01991
01992 return $blResult;
01993 }
01994 }