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/html/forgotpwd.tpl";
00028
00034 protected $_sForgotPwdTemplatePlain = "email/plain/forgotpwd.tpl";
00035
00041 protected $_sNewsletterOptInTemplate = "email/html/newsletteroptin.tpl";
00042
00048 protected $_sNewsletterOptInTemplatePlain = "email/plain/newsletteroptin.tpl";
00049
00055 protected $_sSuggestTemplate = "email/html/suggest.tpl";
00056
00062 protected $_sSuggestTemplatePlain = "email/plain/suggest.tpl";
00063
00069 protected $_sInviteTemplate = "email/html/invite.tpl";
00070
00076 protected $_sInviteTemplatePlain = "email/plain/invite.tpl";
00077
00083 protected $_sSenedNowTemplate = "email/html/sendednow.tpl";
00084
00090 protected $_sSenedNowTemplatePlain = "email/plain/sendednow.tpl";
00091
00097 protected $_sSendDownloadsTemplate = "email/html/senddownloadlinks.tpl";
00098
00104 protected $_sSendDownloadsTemplatePlain = "email/plain/senddownloadlinks.tpl";
00105
00111 protected $_sWishListTemplate = "email/html/wishlist.tpl";
00112
00118 protected $_sWishListTemplatePlain = "email/plain/wishlist.tpl";
00119
00125 protected $_sRegisterTemplate = "email/html/register.tpl";
00126
00132 protected $_sRegisterTemplatePlain = "email/plain/register.tpl";
00133
00139 protected $_sReminderMailTemplate = "email/html/owner_reminder.tpl";
00140
00146 protected $_sOrderUserTemplate = "email/html/order_cust.tpl";
00147
00153 protected $_sOrderUserPlainTemplate = "email/plain/order_cust.tpl";
00154
00160 protected $_sOrderOwnerTemplate = "email/html/order_owner.tpl";
00161
00167 protected $_sOrderOwnerPlainTemplate = "email/plain/order_owner.tpl";
00168
00169
00170
00176 protected $_sOrderUserSubjectTemplate = "email/html/order_cust_subj.tpl";
00177
00183 protected $_sOrderOwnerSubjectTemplate = "email/html/order_owner_subj.tpl";
00184
00190 protected $_sOwnerPricealarmTemplate = "email/html/pricealarm_owner.tpl";
00191
00197 protected $_sPricealamrCustomerTemplate = "email_pricealarm_customer.tpl";
00198
00204 protected $_aShops = array();
00205
00211 protected $_blInlineImgEmail = null;
00212
00218 protected $_aRecipients = array();
00219
00225 protected $_aReplies = array();
00226
00232 protected $_aAttachments = array();
00233
00239 protected $_oSmarty = null;
00240
00246 protected $_aViewData = array();
00247
00253 protected $_oShop = null;
00254
00260 protected $_sCharSet = null;
00261
00265 public function __construct()
00266 {
00267
00268 parent::__construct( true );
00269
00270 $myConfig = $this->getConfig();
00271
00272 $this->_setMailerPluginDir();
00273 $this->setSmtp();
00274
00275 $this->setUseInlineImages( $myConfig->getConfigParam('blInlineImgEmail') );
00276 $this->setMailWordWrap( 100 );
00277
00278 $this->isHtml( true );
00279 $this->setLanguage( "en", $myConfig->getConfigParam( 'sShopDir' )."/core/phpmailer/language/");
00280
00281 $this->_getSmarty();
00282 }
00283
00295 public function __call( $sMethod, $aArgs )
00296 {
00297 if ( defined( 'OXID_PHP_UNIT' ) ) {
00298 if ( substr( $sMethod, 0, 4) == "UNIT" ) {
00299 $sMethod = str_replace( "UNIT", "_", $sMethod );
00300 }
00301 if ( method_exists( $this, $sMethod)) {
00302 return call_user_func_array( array( & $this, $sMethod ), $aArgs );
00303 }
00304 }
00305
00306 throw new oxSystemComponentException( "Function '$sMethod' does not exist or is not accessible! (" . get_class($this) . ")".PHP_EOL);
00307 }
00308
00314 public function getConfig()
00315 {
00316 if ( $this->_oConfig == null ) {
00317 $this->_oConfig = oxConfig::getInstance();
00318 }
00319
00320 return $this->_oConfig;
00321 }
00322
00330 public function setConfig( $oConfig )
00331 {
00332 $this->_oConfig = $oConfig;
00333 }
00334
00335
00341 protected function _getSmarty()
00342 {
00343 if ( $this->_oSmarty === null ) {
00344 $this->_oSmarty = oxUtilsView::getInstance()->getSmarty();
00345 }
00346
00347
00348 $this->_oSmarty->assign( "oEmailView", $this );
00349
00350 return $this->_oSmarty;
00351 }
00352
00360 public function send()
00361 {
00362
00363 if ( count( $this->getRecipient() ) < 1 ) {
00364 return false;
00365 }
00366
00367 $myConfig = $this->getConfig();
00368 $this->setCharSet();
00369
00370 if ( $this->_getUseInlineImages() ) {
00371 $this->_includeImages( $myConfig->getImageDir(), $myConfig->getImageUrl( false, false ), $myConfig->getPictureUrl(null, false),
00372 $myConfig->getImageDir(), $myConfig->getPictureDir(false));
00373 }
00374
00375 $this->_makeOutputProcessing();
00376
00377
00378 if ( $this->getMailer() == 'smtp' ) {
00379 $blRet = $this->_sendMail();
00380
00381
00382 if ( !$blRet ) {
00383
00384 $this->_sendMailErrorMsg();
00385
00386
00387 $this->setMailer( 'mail' );
00388 $blRet = $this->_sendMail();
00389 }
00390 } else {
00391
00392 $this->setMailer( 'mail' );
00393 $blRet = $this->_sendMail();
00394 }
00395
00396 if ( !$blRet ) {
00397
00398 $this->_sendMailErrorMsg();
00399 }
00400
00401 return $blRet;
00402 }
00403
00412 protected function _setSmtpProtocol($sUrl)
00413 {
00414 $sProtocol = '';
00415 $sSmtpHost = $sUrl;
00416 $aMatch = array();
00417 if ( getStr()->preg_match('@^([0-9a-z]+://)?(.*)$@i', $sUrl, $aMatch ) ) {
00418 if ($aMatch[1]) {
00419 if (($aMatch[1] == 'ssl://') || ($aMatch[1] == 'tls://')) {
00420 $this->set( "SMTPSecure", substr($aMatch[1], 0, 3) );
00421 } else {
00422 $sProtocol = $aMatch[1];
00423 }
00424 }
00425 $sSmtpHost = $aMatch[2];
00426 }
00427
00428 return $sProtocol.$sSmtpHost;
00429 }
00430
00438 public function setSmtp( $oShop = null )
00439 {
00440 $myConfig = $this->getConfig();
00441 $oShop = ( $oShop ) ? $oShop : $this->_getShop();
00442
00443 $sSmtpUrl = $this->_setSmtpProtocol($oShop->oxshops__oxsmtp->value);
00444
00445 if ( !$this->_isValidSmtpHost( $sSmtpUrl ) ) {
00446 $this->setMailer( "mail" );
00447 return;
00448 }
00449
00450 $this->setHost( $sSmtpUrl );
00451 $this->setMailer( "smtp" );
00452
00453 if ( $oShop->oxshops__oxsmtpuser->value ) {
00454 $this->_setSmtpAuthInfo( $oShop->oxshops__oxsmtpuser->value, $oShop->oxshops__oxsmtppwd->value );
00455 }
00456
00457 if ( $myConfig->getConfigParam( 'iDebug' ) == 6 ) {
00458 $this->_setSmtpDebug( true );
00459 }
00460 }
00461
00469 protected function _isValidSmtpHost( $sSmtpHost )
00470 {
00471 $blIsSmtp = false;
00472 if ( $sSmtpHost ) {
00473 $sSmtpPort = $this->SMTP_PORT;
00474 $aMatch = array();
00475 if ( getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $sSmtpHost, $aMatch)) {
00476 $sSmtpHost = $aMatch[1];
00477 $sSmtpPort = (int)$aMatch[3];
00478 if (!$sSmtpPort) {
00479 $sSmtpPort = $this->SMTP_PORT;
00480 }
00481 }
00482 if ( $blIsSmtp = (bool) ( $rHandle = @fsockopen( $sSmtpHost, $sSmtpPort, $iErrNo, $sErrStr, 30 )) ) {
00483
00484 fclose( $rHandle );
00485 }
00486 }
00487
00488 return $blIsSmtp;
00489 }
00490
00500 public function sendOrderEmailToUser( $oOrder, $sSubject = null )
00501 {
00502 $myConfig = $this->getConfig();
00503
00504
00505 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00506
00507 $oShop = $this->_getShop();
00508 $this->_setMailParams( $oShop );
00509
00510 $oUser = $oOrder->getOrderUser();
00511 $this->setUser( $oUser );
00512
00513
00514 $oSmarty = $this->_getSmarty();
00515 $this->setViewData( "order", $oOrder);
00516
00517 if ( $myConfig->getConfigParam( "bl_perfLoadReviews" ) ) {
00518 $this->setViewData( "blShowReviewLink", true );
00519 }
00520
00521
00522 $this->_processViewArray();
00523
00524 $this->setBody( $oSmarty->fetch( $this->_sOrderUserTemplate ) );
00525 $this->setAltBody( $oSmarty->fetch( $this->_sOrderUserPlainTemplate ) );
00526
00527
00528 if ( $sSubject === null ) {
00529 if ( $oSmarty->template_exists( $this->_sOrderUserSubjectTemplate) ) {
00530 $sSubject = $oSmarty->fetch( $this->_sOrderUserSubjectTemplate );
00531 } else {
00532 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00533 }
00534 }
00535
00536 $this->setSubject( $sSubject );
00537
00538 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00539
00540 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00541 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00542
00543 $blSuccess = $this->send();
00544
00545 return $blSuccess;
00546 }
00547
00557 public function sendOrderEmailToOwner( $oOrder, $sSubject = null )
00558 {
00559 $myConfig = $this->getConfig();
00560
00561 $oShop = $this->_getShop();
00562
00563
00564 $this->_clearMailer();
00565
00566
00567 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00568
00569 $oUser = $oOrder->getOrderUser();
00570 $this->setUser( $oUser );
00571
00572
00573
00574 $this->setFrom( $oShop->oxshops__oxowneremail->value );
00575
00576 $oLang = oxLang::getInstance();
00577 $iOrderLang = $oLang->getObjectTplLanguage();
00578
00579
00580
00581 if ( $oShop->getLanguage() != $iOrderLang ) {
00582 $oShop = $this->_getShop( $iOrderLang );
00583 }
00584
00585 $this->setSmtp( $oShop );
00586
00587
00588 $oSmarty = $this->_getSmarty();
00589 $this->setViewData( "order", $oOrder );
00590
00591
00592 $this->_processViewArray();
00593
00594 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerTemplate, false ) ) );
00595 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerPlainTemplate, false ) ) );
00596
00597
00598
00599 if ( $sSubject === null ) {
00600 if ( $oSmarty->template_exists( $this->_sOrderOwnerSubjectTemplate) ) {
00601 $sSubject = $oSmarty->fetch( $this->_sOrderOwnerSubjectTemplate );
00602 } else {
00603 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00604 }
00605 }
00606
00607 $this->setSubject( $sSubject );
00608 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oLang->translateString("order") );
00609
00610 if ( $oUser->oxuser__oxusername->value != "admin" )
00611 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00612 $this->setReplyTo( $oUser->oxuser__oxusername->value, $sFullName );
00613
00614 $blSuccess = $this->send();
00615
00616
00617 $oRemark = oxNew( "oxremark" );
00618 $oRemark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
00619 $oRemark->oxremark__oxparentid = new oxField($oUser->getId(), oxField::T_RAW);
00620 $oRemark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
00621 $oRemark->save();
00622
00623
00624 if ( $myConfig->getConfigParam( 'iDebug' ) == 6) {
00625 oxUtils::getInstance()->showMessageAndExit( "" );
00626 }
00627
00628 return $blSuccess;
00629 }
00630
00640 public function sendRegisterConfirmEmail( $oUser, $sSubject = null )
00641 {
00642
00643
00644 $this->setViewData( "contentident", "oxregisteraltemail" );
00645 $this->setViewData( "contentplainident", "oxregisterplainaltemail" );
00646
00647
00648 return $this->sendRegisterEmail( $oUser, $sSubject );
00649 }
00650
00660 public function sendRegisterEmail( $oUser, $sSubject = null )
00661 {
00662
00663 $oUser = $this->_addUserRegisterEmail( $oUser );
00664
00665
00666 $oShop = $this->_getShop();
00667
00668
00669 $this->_setMailParams( $oShop );
00670
00671
00672 $oSmarty = $this->_getSmarty();
00673 $this->setUser( $oUser );
00674
00675
00676 $this->_processViewArray();
00677
00678 $this->setBody( $oSmarty->fetch( $this->_sRegisterTemplate ) );
00679 $this->setAltBody( $oSmarty->fetch( $this->_sRegisterTemplatePlain ) );
00680
00681 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue() );
00682
00683 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00684
00685 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00686 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00687
00688 return $this->send();
00689 }
00690
00700 public function sendForgotPwdEmail( $sEmailAddress, $sSubject = null )
00701 {
00702 $myConfig = $this->getConfig();
00703 $oDb = oxDb::getDb();
00704
00705
00706 $oShop = $this->_getShop();
00707
00708
00709 $oShop = $this->_addForgotPwdEmail( $oShop );
00710
00711
00712 $this->_setMailParams( $oShop );
00713
00714
00715 $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sEmailAddress )." and oxuser.oxpassword != ''";
00716 $sOrder = "";
00717 if ( $myConfig->getConfigParam( 'blMallUsers' )) {
00718 $sOrder = "order by oxshopid = '".$oShop->getId()."' desc";
00719 } else {
00720 $sWhere .= " and oxshopid = '".$oShop->getId()."'";
00721 }
00722
00723 $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00724 if ( ( $sOxId = $oDb->getOne( $sSelect ) ) ) {
00725
00726 $oUser = oxNew( 'oxuser' );
00727 if ( $oUser->load($sOxId) ) {
00728
00729 $oSmarty = $this->_getSmarty();
00730 $this->setUser( $oUser );
00731
00732
00733 $this->_processViewArray();
00734
00735 $this->setBody( $oSmarty->fetch( $this->_sForgotPwdTemplate ) );
00736
00737 $this->setAltBody( $oSmarty->fetch( $this->_sForgotPwdTemplatePlain ) );
00738
00739
00740 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue() );
00741
00742 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00743
00744 $this->setRecipient( $sEmailAddress, $sFullName );
00745 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00746
00747 return $this->send();
00748 }
00749 }
00750
00751 return false;
00752 }
00753
00764 public function sendContactMail( $sEmailAddress = null, $sSubject = null, $sMessage = null )
00765 {
00766
00767
00768 $oShop = $this->_getShop();
00769
00770
00771 $this->_setMailParams( $oShop );
00772
00773 $this->setBody( $sMessage );
00774 $this->setSubject( $sSubject );
00775
00776 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00777 $this->setFrom( $sEmailAddress, "" );
00778 $this->setReplyTo( $sEmailAddress, "" );
00779
00780 return $this->send();
00781 }
00782
00792 public function sendNewsletterDbOptInMail( $oUser, $sSubject = null )
00793 {
00794 $oLang = oxLang::getInstance();
00795
00796
00797 $oUser = $this->_addNewsletterDbOptInMail( $oUser );
00798
00799
00800 $oShop = $this->_getShop();
00801
00802
00803 $this->_setMailParams( $oShop );
00804
00805
00806 $oSmarty = $this->_getSmarty();
00807 $this->setViewData( "subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value) );
00808 $this->setUser( $oUser );
00809
00810
00811 $this->_processViewArray();
00812
00813 $this->setBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplate ) );
00814 $this->setAltBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplatePlain ) );
00815 $this->setSubject( ( $sSubject !== null ) ? $sSubject : oxLang::getInstance()->translateString("EMAIL_NEWSLETTERDBOPTINMAIL_SUBJECT") . " " . $oShop->oxshops__oxname->getRawValue() );
00816
00817 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00818
00819 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00820 $this->setFrom( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00821 $this->setReplyTo( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00822
00823 return $this->send();
00824 }
00825
00833 protected function _getNewsSubsLink( $sId )
00834 {
00835 $myConfig = $this->getConfig();
00836 $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00837
00838 $sUrl = $myConfig->getShopHomeURL().'cl=newsletter&fnc=addme&uid='.$sId;
00839 $sUrl.= ( $iActShopLang ) ? '&lang='.$iActShopLang : "";
00840 return $sUrl;
00841 }
00842
00853 public function sendNewsletterMail( $oNewsLetter, $oUser, $sSubject = null )
00854 {
00855
00856 $oShop = $this->_getShop();
00857
00858
00859 $this->_setMailParams( $oShop );
00860
00861 $sBody = $oNewsLetter->getHtmlText();
00862
00863 if ( !empty($sBody) ) {
00864 $this->setBody( $sBody );
00865 $this->setAltBody( $oNewsLetter->getPlainText() );
00866 } else {
00867 $this->isHtml( false );
00868 $this->setBody( $oNewsLetter->getPlainText() );
00869 }
00870
00871 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue() );
00872
00873 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00874 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00875 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00876
00877 return $this->send();
00878 }
00879
00889 public function sendSuggestMail( $oParams, $oProduct )
00890 {
00891 $myConfig = $this->getConfig();
00892
00893
00894 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00895
00896
00897 $oShop = $this->_getShop( $iCurrLang );
00898
00899
00900 if ( $oProduct->getLanguage() != $iCurrLang ) {
00901 $oProduct->setLanguage( $iCurrLang );
00902 $oProduct->load( $oProduct->getId() );
00903 }
00904
00905
00906
00907 $this->setFrom( $oShop->oxshops__oxinfoemail->value );
00908 $this->setSMTP();
00909
00910
00911 $oSmarty = $this->_getSmarty();
00912 $this->setViewData( "product", $oProduct );
00913 $this->setUser( $oParams );
00914
00915 $sArticleUrl = $oProduct->getLink();
00916
00917
00918 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00919 $sArticleUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sArticleUrl );
00920 $sArticleUrl .= "su=" . $oActiveUser->getId();
00921 }
00922
00923 $this->setViewData( "sArticleUrl", $sArticleUrl );
00924
00925
00926 $this->_processViewArray();
00927
00928 $this->setBody( $oSmarty->fetch( $this->_sSuggestTemplate ) );
00929 $this->setAltBody( $oSmarty->fetch( $this->_sSuggestTemplatePlain ) );
00930 $this->setSubject( $oParams->send_subject );
00931
00932 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
00933 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00934
00935 return $this->send();
00936 }
00937
00946 public function sendInviteMail( $oParams )
00947 {
00948 $myConfig = $this->getConfig();
00949
00950
00951 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00952
00953
00954 $oShop = $this->_getShop( $iCurrLang );
00955
00956
00957 $this->setFrom( $oParams->send_email, $oParams->send_name );
00958 $this->setSMTP();
00959
00960
00961 $oSmarty = oxUtilsView::getInstance()->getSmarty();
00962 $this->setUser( $oParams );
00963
00964 $sHomeUrl = $this->getViewConfig()->getHomeLink();
00965
00966
00967 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00968 $sHomeUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sHomeUrl );
00969 $sHomeUrl .= "su=" . $oActiveUser->getId();
00970 }
00971
00972 if ( is_array($oParams->rec_email) && count($oParams->rec_email) > 0 ) {
00973 foreach ( $oParams->rec_email as $sEmail ) {
00974 if ( !empty( $sEmail ) ) {
00975 $sRegisterUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sHomeUrl );
00976
00977 $sRegisterUrl .= "re=" . md5($sEmail);
00978 $this->setViewData( "sHomeUrl", $sRegisterUrl );
00979
00980
00981 $this->_processViewArray();
00982
00983 $this->setBody( $oSmarty->fetch( $this->_sInviteTemplate ) );
00984
00985 $this->setAltBody( $oSmarty->fetch( $this->_sInviteTemplatePlain ) );
00986 $this->setSubject( $oParams->send_subject );
00987
00988 $this->setRecipient( $sEmail );
00989 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00990 $this->send();
00991 $this->clearAllRecipients();
00992 }
00993 }
00994 return true;
00995 }
00996
00997 return false;
00998 }
00999
01009 public function sendSendedNowMail( $oOrder, $sSubject = null )
01010 {
01011 $myConfig = $this->getConfig();
01012
01013 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01014
01015
01016 $oShop = $this->_getShop( $iOrderLang );
01017
01018
01019 $this->_setMailParams( $oShop );
01020
01021
01022 $oLang = oxLang::getInstance();
01023 $oSmarty = $this->_getSmarty();
01024 $this->setViewData( "order", $oOrder );
01025 $this->setViewData( "shopTemplateDir", $myConfig->getTemplateDir(false) );
01026
01027 if ( $myConfig->getConfigParam( "bl_perfLoadReviews" ) ) {
01028 $this->setViewData( "blShowReviewLink", true );
01029
01030 $oUser = oxNew( 'oxuser' );
01031 $this->setViewData( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01032 }
01033
01034
01035 $this->_processViewArray();
01036
01037
01038 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01039
01040 $iOldTplLang = $oLang->getTplLanguage();
01041 $iOldBaseLang = $oLang->getTplLanguage();
01042 $oLang->setTplLanguage( $iOrderLang );
01043 $oLang->setBaseLanguage( $iOrderLang );
01044
01045 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01046
01047 $myConfig->setAdminMode( false );
01048 $this->setBody( $oSmarty->fetch( $this->_sSenedNowTemplate ) );
01049 $this->setAltBody( $oSmarty->fetch( $this->_sSenedNowTemplatePlain ) );
01050 $myConfig->setAdminMode( true );
01051 $oLang->setTplLanguage( $iOldTplLang );
01052 $oLang->setBaseLanguage( $iOldBaseLang );
01053
01054 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01055
01056
01057 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue() );
01058
01059 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01060
01061 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01062 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01063
01064 return $this->send();
01065 }
01066
01076 public function sendDownloadLinksMail( $oOrder, $sSubject = null )
01077 {
01078 $myConfig = $this->getConfig();
01079
01080 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01081
01082
01083 $oShop = $this->_getShop( $iOrderLang );
01084
01085
01086 $this->_setMailParams( $oShop );
01087
01088
01089 $oLang = oxLang::getInstance();
01090 $oSmarty = $this->_getSmarty();
01091 $this->setViewData( "order", $oOrder );
01092 $this->setViewData( "shopTemplateDir", $myConfig->getTemplateDir(false) );
01093
01094
01095 $oUser = oxNew( 'oxuser' );
01096 $this->setViewData( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01097
01098
01099 $this->_processViewArray();
01100
01101
01102 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01103
01104 $iOldTplLang = $oLang->getTplLanguage();
01105 $iOldBaseLang = $oLang->getTplLanguage();
01106 $oLang->setTplLanguage( $iOrderLang );
01107 $oLang->setBaseLanguage( $iOrderLang );
01108
01109 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01110
01111 $myConfig->setAdminMode( false );
01112 $this->setBody( $oSmarty->fetch( $this->_sSendDownloadsTemplate ) );
01113 $this->setAltBody( $oSmarty->fetch( $this->_sSendDownloadsTemplatePlain ) );
01114 $myConfig->setAdminMode( true );
01115 $oLang->setTplLanguage( $iOldTplLang );
01116 $oLang->setBaseLanguage( $iOldBaseLang );
01117
01118 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01119
01120
01121 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString("EMAIL_SENDDOWNLOADS_SUBJECT") );
01122
01123 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01124
01125 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01126 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01127
01128 return $this->send();
01129 }
01130
01145 public function sendBackupMail( $aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError )
01146 {
01147
01148 $oShop = $this->_getShop();
01149
01150
01151 $this->_setMailParams( $oShop );
01152
01153 $this->setBody( $sMessage );
01154 $this->setSubject( $sSubject );
01155
01156 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
01157 $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
01158
01159 $this->setFrom( $sEmailAddress, "" );
01160 $this->setReplyTo( $sEmailAddress, "" );
01161
01162
01163 $blAttashSucc = true;
01164 $sAttPath = oxUtilsFile::getInstance()->normalizeDir($sAttPath);
01165 foreach ( $aAttFiles as $iNum => $sAttFile ) {
01166 $sFullPath = $sAttPath . $sAttFile;
01167 if ( @is_readable( $sFullPath ) && @is_file( $sFullPath ) ) {
01168 $blAttashSucc = $this->addAttachment( $sFullPath, $sAttFile );
01169 } else {
01170 $blAttashSucc = false;
01171 $aError[] = array( 5, $sAttFile );
01172 }
01173 }
01174
01175 if ( !$blAttashSucc ) {
01176 $aError[] = array( 4, "" );
01177 $this->clearAttachments();
01178 return false;
01179 }
01180
01181 $aStatus[] = 3;
01182 $blSend = $this->send();
01183 $this->clearAttachments();
01184
01185 return $blSend;
01186 }
01187
01198 public function sendEmail( $sTo, $sSubject, $sBody )
01199 {
01200
01201 $this->_setMailParams();
01202
01203 if ( is_array($sTo) ) {
01204 foreach ($sTo as $sAddress) {
01205 $this->setRecipient( $sAddress, "" );
01206 $this->setReplyTo( $sAddress, "" );
01207 }
01208 } else {
01209 $this->setRecipient( $sTo, "" );
01210 $this->setReplyTo( $sTo, "" );
01211 }
01212
01213
01214 $this->isHtml( false );
01215
01216 $this->setSubject( $sSubject );
01217 $this->setBody( $sBody );
01218
01219 return $this->send();
01220 }
01221
01230 public function sendStockReminder( $aBasketContents, $sSubject = null )
01231 {
01232 $blSend = false;
01233
01234 $oArticleList = oxNew( "oxarticlelist" );
01235 $oArticleList->loadStockRemindProducts( $aBasketContents );
01236
01237
01238 if ( $oArticleList->count() ) {
01239 $oShop = $this->_getShop();
01240
01241
01242 $this->_setMailParams( $oShop );
01243 $oLang = oxLang::getInstance();
01244
01245 $oSmarty = $this->_getSmarty();
01246 $this->setViewData( "articles", $oArticleList );
01247
01248
01249 $this->_processViewArray();
01250
01251 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01252 $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01253 $this->setBody( $oSmarty->fetch( $this->getConfig()->getTemplatePath( $this->_sReminderMailTemplate, false ) ) );
01254 $this->setAltBody( "" );
01255 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_STOCKREMINDER_SUBJECT' ) );
01256
01257 $blSend = $this->send();
01258 }
01259
01260 return $blSend;
01261 }
01262
01271 public function sendWishlistMail( $oParams )
01272 {
01273 $myConfig = $this->getConfig();
01274
01275 $this->_clearMailer();
01276
01277
01278 $oShop = $this->_getShop();
01279
01280
01281 $this->setFrom( $oParams->send_email, $oParams->send_name );
01282 $this->setSMTP();
01283
01284
01285 $oSmarty = $this->_getSmarty();
01286 $this->setUser( $oParams );
01287
01288
01289 $this->_processViewArray();
01290
01291 $this->setBody( $oSmarty->fetch( $this->_sWishListTemplate ) );
01292 $this->setAltBody( $oSmarty->fetch( $this->_sWishListTemplatePlain ) );
01293 $this->setSubject( $oParams->send_subject );
01294
01295 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
01296 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01297
01298 return $this->send();
01299 }
01300
01311 public function sendPriceAlarmNotification( $aParams, $oAlarm, $sSubject = null )
01312 {
01313 $this->_clearMailer();
01314 $oShop = $this->_getShop();
01315
01316
01317 $this->_setMailParams( $oShop );
01318
01319 $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01320
01321 $oArticle = oxNew( "oxarticle" );
01322 $oArticle->setSkipAbPrice( true );
01323 $oArticle->loadInLang( $iAlarmLang, $aParams['aid'] );
01324 $oLang = oxLang::getInstance();
01325
01326
01327 $oSmarty = $this->_getSmarty();
01328 $this->setViewData( "product", $oArticle );
01329 $this->setViewData( "email", $aParams['email']);
01330 $this->setViewData( "bidprice", $oLang->formatCurrency( $oAlarm->oxpricealarm__oxprice->value, $oCur ) );
01331
01332
01333 $this->_processViewArray();
01334
01335 $this->setRecipient( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01336 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_PRICEALARM_OWNER_SUBJECT', $iAlarmLang ) . " " . $oArticle->oxarticles__oxtitle->getRawValue() );
01337 $this->setBody( $oSmarty->fetch( $this->_sOwnerPricealarmTemplate ) );
01338 $this->setFrom( $aParams['email'], "" );
01339 $this->setReplyTo( $aParams['email'], "" );
01340
01341 return $this->send();
01342 }
01343
01355 public function sendPricealarmToCustomer( $sRecipient, $oAlarm, $sBody = null, $sReturnMailBody = null )
01356 {
01357 $this->_clearMailer();
01358
01359 $oShop = $this->_getShop();
01360
01361 if ( $oShop->getId() != $oAlarm->oxpricealarm__oxshopid->value) {
01362 $oShop = oxNew( "oxshop" );
01363 $oShop->load( $oAlarm->oxpricealarm__oxshopid->value);
01364 $this->setShop( $oShop );
01365 }
01366
01367
01368 $this->_setMailParams( $oShop );
01369
01370
01371 $oSmarty = $this->_getSmarty();
01372
01373 $this->setViewData( "product", $oAlarm->getArticle() );
01374 $this->setViewData( "oPriceAlarm", $oAlarm );
01375 $this->setViewData( "bidprice", $oAlarm->getFProposedPrice() );
01376 $this->setViewData( "currency", $oAlarm->getPriceAlarmCurrency() );
01377
01378
01379 $this->_processViewArray();
01380
01381 $this->setRecipient( $sRecipient, $sRecipient );
01382 $this->setSubject( $oShop->oxshops__oxname->value );
01383
01384 if ( $sBody === null ) {
01385 $sBody = $oSmarty->fetch( $this->_sPricealamrCustomerTemplate );
01386 }
01387
01388 $this->setBody( $sBody );
01389
01390 $this->addAddress( $sRecipient, $sRecipient );
01391 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01392
01393 if ( $sReturnMailBody ) {
01394 return $this->getBody();
01395 } else {
01396 return $this->send();
01397 }
01398 }
01399
01411 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01412 {
01413 $sBody = $this->getBody();
01414 if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01415
01416 $oFileUtils = oxUtilsFile::getInstance();
01417 $blReSetBody = false;
01418
01419
01420 $sDynImageDir = $oFileUtils->normalizeDir( $sDynImageDir );
01421 $sImageDir = $oFileUtils->normalizeDir( $sImageDir );
01422 $sImageDirNoSSL = $oFileUtils->normalizeDir( $sImageDirNoSSL );
01423
01424 if (is_array($matches) && count($matches)) {
01425 $aImageCache = array();
01426 $myUtils = oxUtils::getInstance();
01427 $myUtilsObject = oxUtilsObject::getInstance();
01428 $oImgGenerator = oxNew( "oxDynImgGenerator" );
01429
01430 foreach ($matches as $aImage) {
01431
01432 $image = $aImage[1];
01433 $sFileName = '';
01434 if ( strpos( $image, $sDynImageDir ) === 0 ) {
01435 $sFileName = $oFileUtils->normalizeDir( $sAbsDynImageDir ) . str_replace( $sDynImageDir, '', $image );
01436 } elseif ( strpos( $image, $sImageDir ) === 0 ) {
01437 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDir, '', $image );
01438 } elseif ( strpos( $image, $sImageDirNoSSL ) === 0 ) {
01439 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDirNoSSL, '', $image );
01440 }
01441
01442 if ( $sFileName && !@is_readable( $sFileName ) ) {
01443 $sFileName = $oImgGenerator->getImagePath( $sFileName );
01444 }
01445
01446 if ( $sFileName ) {
01447 $sCId = '';
01448 if ( isset( $aImageCache[$sFileName] ) && $aImageCache[$sFileName] ) {
01449 $sCId = $aImageCache[$sFileName];
01450 } else {
01451 $sCId = $myUtilsObject->generateUID();
01452 $sMIME = $myUtils->oxMimeContentType($sFileName);
01453 if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01454 if ( $this->addEmbeddedImage( $sFileName, $sCId, "image", "base64", $sMIME ) ) {
01455 $aImageCache[$sFileName] = $sCId;
01456 } else {
01457 $sCId = '';
01458 }
01459 }
01460 }
01461 if ( $sCId && $sCId == $aImageCache[$sFileName] ) {
01462 if ( $sReplTag = str_replace( $image, 'cid:'.$sCId, $aImage[0] ) ) {
01463 $sBody = str_replace($aImage[0], $sReplTag, $sBody );
01464 $blReSetBody = true;
01465 }
01466 }
01467 }
01468 }
01469 }
01470
01471 if ( $blReSetBody ) {
01472 $this->setBody( $sBody );
01473 }
01474 }
01475 }
01476
01484 public function setSubject( $sSubject = null )
01485 {
01486
01487 $sSubject = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sSubject);
01488
01489 $this->set( "Subject", $sSubject );
01490 }
01491
01497 public function getSubject()
01498 {
01499 return $this->Subject;
01500 }
01501
01511 public function setBody( $sBody = null, $blClearSid = true )
01512 {
01513 if ( $blClearSid ) {
01514 $sBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sBody);
01515 }
01516
01517 $this->set( "Body", $sBody );
01518 }
01519
01525 public function getBody()
01526 {
01527 return $this->Body;
01528 }
01529
01539 public function setAltBody( $sAltBody = null, $blClearSid = true )
01540 {
01541 if ( $blClearSid ) {
01542 $sAltBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sAltBody);
01543 }
01544
01545
01546 $sAltBody = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sAltBody);
01547
01548 $this->set( "AltBody", $sAltBody );
01549 }
01550
01556 public function getAltBody()
01557 {
01558 return $this->AltBody;
01559 }
01560
01569 public function setRecipient( $sAddress = null, $sName = null )
01570 {
01571 try {
01572 parent::AddAddress( $sAddress, $sName );
01573
01574
01575 $this->_aRecipients[] = array( $sAddress, $sName );
01576 } catch( Exception $oEx ) {
01577 }
01578 }
01579
01587 public function getRecipient()
01588 {
01589 return $this->_aRecipients;
01590 }
01591
01598 public function clearAllRecipients()
01599 {
01600 $this->_aRecipients = array();
01601 parent::clearAllRecipients();
01602 }
01603
01615 public function setReplyTo( $sEmail = null, $sName = null )
01616 {
01617 if ( !oxUtils::getInstance()->isValidEmail( $sEmail ) ) {
01618 $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01619 }
01620
01621 $this->_aReplies[] = array( $sEmail, $sName );
01622
01623 try {
01624 parent::addReplyTo( $sEmail, $sName );
01625 } catch( Exception $oEx ) {
01626 }
01627 }
01628
01634 public function getReplyTo()
01635 {
01636 return $this->_aReplies;
01637 }
01638
01644 public function clearReplyTos()
01645 {
01646 $this->_aReplies = array();
01647 parent::clearReplyTos();
01648 }
01649
01658 public function setFrom( $sFromAdress, $sFromName = null )
01659 {
01660
01661
01662
01663 $sFromAdress = substr($sFromAdress, 0, 150);
01664 $sFromName = substr($sFromName, 0, 150);
01665
01666 try {
01667 parent::setFrom( $sFromAdress, $sFromName );
01668 } catch( Exception $oEx ) {
01669 }
01670 }
01671
01677 public function getFrom()
01678 {
01679 return $this->From;
01680 }
01681
01687 public function getFromName()
01688 {
01689 return $this->FromName;
01690 }
01691
01700 public function setCharSet( $sCharSet = null )
01701 {
01702 if ( $sCharSet ) {
01703 $this->_sCharSet = $sCharSet;
01704 } else {
01705 $this->_sCharSet = oxLang::getInstance()->translateString( "charset" );
01706 }
01707 $this->set( "CharSet", $this->_sCharSet );
01708 }
01709
01717 public function setMailer( $sMailer = null )
01718 {
01719 $this->set( "Mailer", $sMailer );
01720 }
01721
01727 public function getMailer()
01728 {
01729 return $this->Mailer;
01730 }
01731
01739 public function setHost( $sHost = null )
01740 {
01741 $this->set( "Host", $sHost );
01742 }
01743
01749 public function getErrorInfo()
01750 {
01751 return $this->ErrorInfo;
01752 }
01753
01762 public function setMailWordWrap( $iWordWrap = null )
01763 {
01764 $this->set( "WordWrap", $iWordWrap );
01765 }
01766
01774 public function setUseInlineImages( $blUseImages = null )
01775 {
01776 $this->_blInlineImgEmail = $blUseImages;
01777 }
01778
01789 public function addAttachment( $sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01790 {
01791 $this->_aAttachments[] = array( $sAttPath, $sAttFile, $sEncoding, $sType );
01792 $blResult = false;
01793
01794 try {
01795 $blResult = parent::addAttachment( $sAttPath, $sAttFile, $sEncoding, $sType );
01796 } catch( Exception $oEx ) {
01797 }
01798
01799 return $blResult;
01800 }
01801
01813 public function addEmbeddedImage( $sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01814 {
01815 $this->_aAttachments[] = array( $sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid );
01816 return parent::addEmbeddedImage( $sFullPath, $sCid, $sAttFile, $sEncoding, $sType );
01817 }
01818
01824 public function getAttachments()
01825 {
01826 return $this->_aAttachments;
01827 }
01828
01834 public function clearAttachments()
01835 {
01836 $this->_aAttachments = array();
01837 return parent::clearAttachments();
01838 }
01839
01849 public function headerLine($sName, $sValue)
01850 {
01851 if (stripos($sName, 'X-') !== false) {
01852 return;
01853 }
01854 return parent::headerLine($sName, $sValue);
01855 }
01856
01862 protected function _getUseInlineImages()
01863 {
01864 return $this->_blInlineImgEmail;
01865 }
01866
01872 protected function _sendMailErrorMsg()
01873 {
01874
01875 $sToAdress = "";
01876 $sToName = "";
01877
01878 $aRecipients = $this->getRecipient();
01879
01880 $sOwnerMessage = "Error sending eMail(". $this->getSubject().") to: \n\n";
01881
01882 foreach ( $aRecipients as $aEMail ) {
01883 $sOwnerMessage .= $aEMail[0];
01884 $sOwnerMessage .= ( !empty($aEMail[1]) ) ? ' (' . $aEMail[1] . ')' : '';
01885 $sOwnerMessage .= " \n ";
01886 }
01887 $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01888
01889
01890 $oShop = $this->_getShop();
01891
01892 $blRet = @mail( $oShop->oxshops__oxorderemail->value, "eMail problem in shop!", $sOwnerMessage);
01893
01894 return $blRet;
01895 }
01896
01906 protected function _addUserInfoOrderEMail( $oOrder )
01907 {
01908 return $oOrder;
01909 }
01910
01920 protected function _addUserRegisterEmail( $oUser )
01921 {
01922 return $oUser;
01923 }
01924
01934 protected function _addForgotPwdEmail( $oShop )
01935 {
01936 return $oShop;
01937 }
01938
01948 protected function _addNewsletterDbOptInMail( $oUser )
01949 {
01950 return $oUser;
01951 }
01952
01958 protected function _clearMailer()
01959 {
01960 $this->clearAllRecipients();
01961 $this->clearReplyTos();
01962 $this->clearAttachments();
01963
01964
01965 $this->error_count = 0;
01966 $this->ErrorInfo = '';
01967 }
01968
01976 protected function _setMailParams( $oShop = null )
01977 {
01978 $this->_clearMailer();
01979
01980 if ( !$oShop ) {
01981 $oShop = $this->_getShop();
01982 }
01983
01984 $this->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01985 $this->setSmtp( $oShop );
01986 }
01987
01997 protected function _getShop( $iLangId = null, $iShopId = null )
01998 {
01999
02000 if ( isset( $this->_oShop ) ) {
02001 return $this->_oShop;
02002 }
02003
02004 $myConfig = $this->getConfig();
02005
02006 if ( $iLangId === null ) {
02007 $oShop = $myConfig->getActiveShop();
02008 } else {
02009 $oShop = oxNew( 'oxshop' );
02010 $oShop->loadInLang( $iLangId, $myConfig->getShopId() );
02011 }
02012
02013 return $this->_oShop = $oShop;
02014 }
02015
02024 protected function _setSmtpAuthInfo( $sUserName = null, $sUserPassword = null )
02025 {
02026 $this->set( "SMTPAuth", true );
02027 $this->set( "Username", $sUserName );
02028 $this->set( "Password", $sUserPassword );
02029 }
02030
02038 protected function _setSmtpDebug( $blDebug = null )
02039 {
02040 $this->set( "SMTPDebug", $blDebug );
02041 }
02042
02048 protected function _setMailerPluginDir()
02049 {
02050 $this->set( "PluginDir", getShopBasePath() . "core/phpmailer/" );
02051 }
02052
02059 protected function _makeOutputProcessing()
02060 {
02061 $oOutput = oxNew( "oxoutput" );
02062 $this->setBody( $oOutput->process($this->getBody(), "oxemail") );
02063 $this->setAltBody( $oOutput->process($this->getAltBody(), "oxemail") );
02064 $oOutput->processEmail( $this );
02065 }
02066
02072 protected function _sendMail()
02073 {
02074 $blResult = false;
02075 try {
02076 $blResult = parent::send();
02077 } catch( Exception $oEx ) {
02078 }
02079
02080 return $blResult;
02081 }
02082
02083
02089 protected function _processViewArray()
02090 {
02091 $oSmarty = $this->_getSmarty();
02092 $oOutputProcessor = oxNew( "oxoutput" );
02093
02094
02095 foreach ( $this->_aViewData as $sKey => $sValue ) {
02096 $oSmarty->assign( $sKey, $sValue );
02097 }
02098
02099
02100 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
02101
02102 foreach ( $aNewSmartyArray as $key => $val ) {
02103 $oSmarty->assign( $key, $val );
02104 }
02105 }
02106
02112 public function getCharset()
02113 {
02114 if ( !$this->_sCharSet ) {
02115 return oxLang::getInstance()->translateString("charset");
02116 } else {
02117 return $this->CharSet;
02118 }
02119 }
02120
02126 public function getShop()
02127 {
02128 return $this->_getShop();
02129 }
02130
02138 public function setShop( $oShop )
02139 {
02140 $this->_oShop = $oShop;
02141 }
02142
02148 public function getViewConfig()
02149 {
02150 return $this->getConfig()->getActiveView()->getViewConfig();
02151 }
02152
02158 public function getView()
02159 {
02160 return $this->getConfig()->getActiveView();
02161 }
02162
02168 public function getCurrency()
02169 {
02170 $oConfig = oxConfig::getInstance();
02171
02172 return $oConfig->getActShopCurrencyObject();
02173 }
02174
02183 public function setViewData( $sKey, $sValue )
02184 {
02185 $this->_aViewData[$sKey] = $sValue;
02186 }
02187
02193 public function getViewData()
02194 {
02195 return $this->_aViewData;
02196 }
02197
02205 public function getViewDataItem( $sKey )
02206 {
02207 if ( isset($this->_aViewData[$sKey]) ) {
02208 return $this->_aViewData;
02209 }
02210 }
02211
02219 public function setUser( $oUser)
02220 {
02221 $this->_aViewData["oUser"] = $oUser;
02222 }
02223
02229 public function getUser()
02230 {
02231 return $this->_aViewData["oUser"];
02232 }
02233
02241 public function getOrderFileList( $sOrderId )
02242 {
02243 $oOrderList = oxNew('oxOrderFileList');
02244 $oOrderList->loadOrderFiles( $sOrderId );
02245
02246 return $oOrderList;
02247 }
02248
02249 }