00001 <?php
00005 require oxRegistry::getConfig()->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 = oxRegistry::getConfig();
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 = oxRegistry::get("oxUtilsView")->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 = oxRegistry::getLang();
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
00615 $blSuccess = $this->send();
00616
00617
00618 $oRemark = oxNew( "oxremark" );
00619 $oRemark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
00620 $oRemark->oxremark__oxparentid = new oxField($oUser->getId(), oxField::T_RAW);
00621 $oRemark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
00622 $oRemark->save();
00623
00624
00625 if ( $myConfig->getConfigParam( 'iDebug' ) == 6) {
00626 oxRegistry::getUtils()->showMessageAndExit( "" );
00627 }
00628
00629 return $blSuccess;
00630 }
00631
00641 public function sendRegisterConfirmEmail( $oUser, $sSubject = null )
00642 {
00643
00644
00645 $this->setViewData( "contentident", "oxregisteraltemail" );
00646 $this->setViewData( "contentplainident", "oxregisterplainaltemail" );
00647
00648
00649 return $this->sendRegisterEmail( $oUser, $sSubject );
00650 }
00651
00661 public function sendRegisterEmail( $oUser, $sSubject = null )
00662 {
00663
00664 $oUser = $this->_addUserRegisterEmail( $oUser );
00665
00666
00667 $oShop = $this->_getShop();
00668
00669
00670 $this->_setMailParams( $oShop );
00671
00672
00673 $oSmarty = $this->_getSmarty();
00674 $this->setUser( $oUser );
00675
00676
00677 $this->_processViewArray();
00678
00679 $this->setBody( $oSmarty->fetch( $this->_sRegisterTemplate ) );
00680 $this->setAltBody( $oSmarty->fetch( $this->_sRegisterTemplatePlain ) );
00681
00682 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue() );
00683
00684 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00685
00686 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00687 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00688
00689 return $this->send();
00690 }
00691
00701 public function sendForgotPwdEmail( $sEmailAddress, $sSubject = null )
00702 {
00703 $myConfig = $this->getConfig();
00704 $oDb = oxDb::getDb();
00705
00706
00707 $oShop = $this->_getShop();
00708
00709
00710 $oShop = $this->_addForgotPwdEmail( $oShop );
00711
00712
00713 $this->_setMailParams( $oShop );
00714
00715
00716 $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sEmailAddress )." and oxuser.oxpassword != ''";
00717 $sOrder = "";
00718 if ( $myConfig->getConfigParam( 'blMallUsers' )) {
00719 $sOrder = "order by oxshopid = '".$oShop->getId()."' desc";
00720 } else {
00721 $sWhere .= " and oxshopid = '".$oShop->getId()."'";
00722 }
00723
00724 $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00725 if ( ( $sOxId = $oDb->getOne( $sSelect ) ) ) {
00726
00727 $oUser = oxNew( 'oxuser' );
00728 if ( $oUser->load($sOxId) ) {
00729
00730 $oSmarty = $this->_getSmarty();
00731 $this->setUser( $oUser );
00732
00733
00734 $this->_processViewArray();
00735
00736 $this->setBody( $oSmarty->fetch( $this->_sForgotPwdTemplate ) );
00737
00738 $this->setAltBody( $oSmarty->fetch( $this->_sForgotPwdTemplatePlain ) );
00739
00740
00741 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue() );
00742
00743 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00744
00745 $this->setRecipient( $sEmailAddress, $sFullName );
00746 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00747
00748 if ( !$this->send() ) {
00749 return -1;
00750 }
00751 return true;
00752 }
00753 }
00754
00755 return false;
00756 }
00757
00768 public function sendContactMail( $sEmailAddress = null, $sSubject = null, $sMessage = null )
00769 {
00770
00771
00772 $oShop = $this->_getShop();
00773
00774
00775 $this->_setMailParams( $oShop );
00776
00777 $this->setBody( $sMessage );
00778 $this->setSubject( $sSubject );
00779
00780 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00781 $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
00782 $this->setReplyTo( $sEmailAddress, "" );
00783
00784 return $this->send();
00785 }
00786
00796 public function sendNewsletterDbOptInMail( $oUser, $sSubject = null )
00797 {
00798 $oLang = oxRegistry::getLang();
00799
00800
00801 $oUser = $this->_addNewsletterDbOptInMail( $oUser );
00802
00803
00804 $oShop = $this->_getShop();
00805
00806
00807 $this->_setMailParams( $oShop );
00808
00809
00810 $oSmarty = $this->_getSmarty();
00811 $sConfirmCode = md5($oUser->oxuser__oxusername->value.$oUser->oxuser__oxpasssalt->value);
00812 $this->setViewData( "subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value, $sConfirmCode ) );
00813 $this->setUser( $oUser );
00814
00815
00816 $this->_processViewArray();
00817
00818 $this->setBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplate ) );
00819 $this->setAltBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplatePlain ) );
00820 $this->setSubject( ( $sSubject !== null ) ? $sSubject : oxRegistry::getLang()->translateString("EMAIL_NEWSLETTERDBOPTINMAIL_SUBJECT") . " " . $oShop->oxshops__oxname->getRawValue() );
00821
00822 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00823
00824 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00825 $this->setFrom( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00826 $this->setReplyTo( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00827
00828 return $this->send();
00829 }
00830
00839 protected function _getNewsSubsLink( $sId, $sConfirmCode = null )
00840 {
00841 $myConfig = $this->getConfig();
00842 $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00843
00844 $sUrl = $myConfig->getShopHomeURL().'cl=newsletter&fnc=addme&uid='.$sId;
00845 $sUrl.= '&lang='.$iActShopLang;
00846 $sUrl.= ( $sConfirmCode ) ? '&confirm='.$sConfirmCode : "";
00847 return $sUrl;
00848 }
00849
00860 public function sendNewsletterMail( $oNewsLetter, $oUser, $sSubject = null )
00861 {
00862
00863 $oShop = $this->_getShop();
00864
00865
00866 $this->_setMailParams( $oShop );
00867
00868 $sBody = $oNewsLetter->getHtmlText();
00869
00870 if ( !empty($sBody) ) {
00871 $this->setBody( $sBody );
00872 $this->setAltBody( $oNewsLetter->getPlainText() );
00873 } else {
00874 $this->isHtml( false );
00875 $this->setBody( $oNewsLetter->getPlainText() );
00876 }
00877
00878 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue() );
00879
00880 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00881 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00882 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00883
00884 return $this->send();
00885 }
00886
00896 public function sendSuggestMail( $oParams, $oProduct )
00897 {
00898 $myConfig = $this->getConfig();
00899
00900
00901 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00902
00903
00904 $oShop = $this->_getShop( $iCurrLang );
00905
00906
00907 if ( $oProduct->getLanguage() != $iCurrLang ) {
00908 $oProduct->setLanguage( $iCurrLang );
00909 $oProduct->load( $oProduct->getId() );
00910 }
00911
00912
00913
00914 $this->setFrom( $oShop->oxshops__oxinfoemail->value );
00915 $this->setSMTP();
00916
00917
00918 $oSmarty = $this->_getSmarty();
00919 $this->setViewData( "product", $oProduct );
00920 $this->setUser( $oParams );
00921
00922 $sArticleUrl = $oProduct->getLink();
00923
00924
00925 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00926 $sArticleUrl = oxRegistry::get("oxUtilsUrl")->appendParamSeparator( $sArticleUrl );
00927 $sArticleUrl .= "su=" . $oActiveUser->getId();
00928 }
00929
00930 $this->setViewData( "sArticleUrl", $sArticleUrl );
00931
00932
00933 $this->_processViewArray();
00934
00935 $this->setBody( $oSmarty->fetch( $this->_sSuggestTemplate ) );
00936 $this->setAltBody( $oSmarty->fetch( $this->_sSuggestTemplatePlain ) );
00937 $this->setSubject( $oParams->send_subject );
00938
00939 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
00940 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00941
00942 return $this->send();
00943 }
00944
00953 public function sendInviteMail( $oParams )
00954 {
00955 $myConfig = $this->getConfig();
00956
00957
00958 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00959
00960
00961 $oShop = $this->_getShop( $iCurrLang );
00962
00963
00964 $this->setFrom( $oParams->send_email, $oParams->send_name );
00965 $this->setSMTP();
00966
00967
00968 $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00969 $this->setUser( $oParams );
00970
00971 $sHomeUrl = $this->getViewConfig()->getHomeLink();
00972
00973
00974 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00975 $sHomeUrl = oxRegistry::get("oxUtilsUrl")->appendParamSeparator( $sHomeUrl );
00976 $sHomeUrl .= "su=" . $oActiveUser->getId();
00977 }
00978
00979 if ( is_array($oParams->rec_email) && count($oParams->rec_email) > 0 ) {
00980 foreach ( $oParams->rec_email as $sEmail ) {
00981 if ( !empty( $sEmail ) ) {
00982 $sRegisterUrl = oxRegistry::get("oxUtilsUrl")->appendParamSeparator( $sHomeUrl );
00983
00984 $sRegisterUrl .= "re=" . md5($sEmail);
00985 $this->setViewData( "sHomeUrl", $sRegisterUrl );
00986
00987
00988 $this->_processViewArray();
00989
00990 $this->setBody( $oSmarty->fetch( $this->_sInviteTemplate ) );
00991
00992 $this->setAltBody( $oSmarty->fetch( $this->_sInviteTemplatePlain ) );
00993 $this->setSubject( $oParams->send_subject );
00994
00995 $this->setRecipient( $sEmail );
00996 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00997 $this->send();
00998 $this->clearAllRecipients();
00999 }
01000 }
01001 return true;
01002 }
01003
01004 return false;
01005 }
01006
01016 public function sendSendedNowMail( $oOrder, $sSubject = null )
01017 {
01018 $myConfig = $this->getConfig();
01019
01020 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01021
01022
01023 $oShop = $this->_getShop( $iOrderLang );
01024
01025
01026 $this->_setMailParams( $oShop );
01027
01028
01029 $oLang = oxRegistry::getLang();
01030 $oSmarty = $this->_getSmarty();
01031 $this->setViewData( "order", $oOrder );
01032 $this->setViewData( "shopTemplateDir", $myConfig->getTemplateDir(false) );
01033
01034 if ( $myConfig->getConfigParam( "bl_perfLoadReviews" ) ) {
01035 $this->setViewData( "blShowReviewLink", true );
01036 $oUser = oxNew( 'oxuser' );
01037 $this->setViewData( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01038 }
01039
01040
01041 $this->_processViewArray();
01042
01043
01044 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01045
01046 $iOldTplLang = $oLang->getTplLanguage();
01047 $iOldBaseLang = $oLang->getTplLanguage();
01048 $oLang->setTplLanguage( $iOrderLang );
01049 $oLang->setBaseLanguage( $iOrderLang );
01050
01051 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01052
01053 $myConfig->setAdminMode( false );
01054 $this->setBody( $oSmarty->fetch( $this->_sSenedNowTemplate ) );
01055 $this->setAltBody( $oSmarty->fetch( $this->_sSenedNowTemplatePlain ) );
01056 $myConfig->setAdminMode( true );
01057 $oLang->setTplLanguage( $iOldTplLang );
01058 $oLang->setBaseLanguage( $iOldBaseLang );
01059
01060 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01061
01062
01063 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue() );
01064
01065 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01066
01067 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01068 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01069
01070 return $this->send();
01071 }
01072
01082 public function sendDownloadLinksMail( $oOrder, $sSubject = null )
01083 {
01084 $myConfig = $this->getConfig();
01085
01086 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01087
01088
01089 $oShop = $this->_getShop( $iOrderLang );
01090
01091
01092 $this->_setMailParams( $oShop );
01093
01094
01095 $oLang = oxRegistry::getLang();
01096 $oSmarty = $this->_getSmarty();
01097 $this->setViewData( "order", $oOrder );
01098 $this->setViewData( "shopTemplateDir", $myConfig->getTemplateDir(false) );
01099
01100 $oUser = oxNew( 'oxuser' );
01101 $this->setViewData( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01102
01103
01104 $this->_processViewArray();
01105
01106
01107 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01108
01109 $iOldTplLang = $oLang->getTplLanguage();
01110 $iOldBaseLang = $oLang->getTplLanguage();
01111 $oLang->setTplLanguage( $iOrderLang );
01112 $oLang->setBaseLanguage( $iOrderLang );
01113
01114 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01115
01116 $myConfig->setAdminMode( false );
01117 $this->setBody( $oSmarty->fetch( $this->_sSendDownloadsTemplate ) );
01118 $this->setAltBody( $oSmarty->fetch( $this->_sSendDownloadsTemplatePlain ) );
01119 $myConfig->setAdminMode( true );
01120 $oLang->setTplLanguage( $iOldTplLang );
01121 $oLang->setBaseLanguage( $iOldBaseLang );
01122
01123 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01124
01125
01126 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString("EMAIL_SENDDOWNLOADS_SUBJECT", null, false) );
01127
01128 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01129
01130 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01131 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01132
01133 return $this->send();
01134 }
01135
01150 public function sendBackupMail( $aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError )
01151 {
01152
01153 $oShop = $this->_getShop();
01154
01155
01156 $this->_setMailParams( $oShop );
01157
01158 $this->setBody( $sMessage );
01159 $this->setSubject( $sSubject );
01160
01161 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
01162 $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
01163
01164 $this->setFrom( $sEmailAddress, "" );
01165 $this->setReplyTo( $sEmailAddress, "" );
01166
01167
01168 $blAttashSucc = true;
01169 $sAttPath = oxRegistry::get("oxUtilsFile")->normalizeDir($sAttPath);
01170 foreach ( $aAttFiles as $iNum => $sAttFile ) {
01171 $sFullPath = $sAttPath . $sAttFile;
01172 if ( @is_readable( $sFullPath ) && @is_file( $sFullPath ) ) {
01173 $blAttashSucc = $this->addAttachment( $sFullPath, $sAttFile );
01174 } else {
01175 $blAttashSucc = false;
01176 $aError[] = array( 5, $sAttFile );
01177 }
01178 }
01179
01180 if ( !$blAttashSucc ) {
01181 $aError[] = array( 4, "" );
01182 $this->clearAttachments();
01183 return false;
01184 }
01185
01186 $aStatus[] = 3;
01187 $blSend = $this->send();
01188 $this->clearAttachments();
01189
01190 return $blSend;
01191 }
01192
01203 public function sendEmail( $sTo, $sSubject, $sBody )
01204 {
01205
01206 $this->_setMailParams();
01207
01208 if ( is_array($sTo) ) {
01209 foreach ($sTo as $sAddress) {
01210 $this->setRecipient( $sAddress, "" );
01211 $this->setReplyTo( $sAddress, "" );
01212 }
01213 } else {
01214 $this->setRecipient( $sTo, "" );
01215 $this->setReplyTo( $sTo, "" );
01216 }
01217
01218
01219 $this->isHtml( false );
01220
01221 $this->setSubject( $sSubject );
01222 $this->setBody( $sBody );
01223
01224 return $this->send();
01225 }
01226
01235 public function sendStockReminder( $aBasketContents, $sSubject = null )
01236 {
01237 $blSend = false;
01238
01239 $oArticleList = oxNew( "oxarticlelist" );
01240 $oArticleList->loadStockRemindProducts( $aBasketContents );
01241
01242
01243 if ( $oArticleList->count() ) {
01244 $oShop = $this->_getShop();
01245
01246
01247 $this->_setMailParams( $oShop );
01248 $oLang = oxRegistry::getLang();
01249
01250 $oSmarty = $this->_getSmarty();
01251 $this->setViewData( "articles", $oArticleList );
01252
01253
01254 $this->_processViewArray();
01255
01256 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01257 $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01258 $this->setBody( $oSmarty->fetch( $this->getConfig()->getTemplatePath( $this->_sReminderMailTemplate, false ) ) );
01259 $this->setAltBody( "" );
01260 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_STOCKREMINDER_SUBJECT' ) );
01261
01262 $blSend = $this->send();
01263 }
01264
01265 return $blSend;
01266 }
01267
01276 public function sendWishlistMail( $oParams )
01277 {
01278 $myConfig = $this->getConfig();
01279
01280 $this->_clearMailer();
01281
01282
01283 $oShop = $this->_getShop();
01284
01285
01286 $this->setFrom( $oParams->send_email, $oParams->send_name );
01287 $this->setSMTP();
01288
01289
01290 $oSmarty = $this->_getSmarty();
01291 $this->setUser( $oParams );
01292
01293
01294 $this->_processViewArray();
01295
01296 $this->setBody( $oSmarty->fetch( $this->_sWishListTemplate ) );
01297 $this->setAltBody( $oSmarty->fetch( $this->_sWishListTemplatePlain ) );
01298 $this->setSubject( $oParams->send_subject );
01299
01300 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
01301 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01302
01303 return $this->send();
01304 }
01305
01316 public function sendPriceAlarmNotification( $aParams, $oAlarm, $sSubject = null )
01317 {
01318 $this->_clearMailer();
01319 $oShop = $this->_getShop();
01320
01321
01322 $this->_setMailParams( $oShop );
01323
01324 $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01325
01326 $oArticle = oxNew( "oxarticle" );
01327
01328 $oArticle->loadInLang( $iAlarmLang, $aParams['aid'] );
01329 $oLang = oxRegistry::getLang();
01330
01331
01332 $oSmarty = $this->_getSmarty();
01333 $this->setViewData( "product", $oArticle );
01334 $this->setViewData( "email", $aParams['email']);
01335 $this->setViewData( "bidprice", $oLang->formatCurrency( $oAlarm->oxpricealarm__oxprice->value, $oCur ) );
01336
01337
01338 $this->_processViewArray();
01339
01340 $this->setRecipient( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->value );
01341 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_PRICEALARM_OWNER_SUBJECT', $iAlarmLang ) . " " . $oArticle->oxarticles__oxtitle->value );
01342 $this->setBody( $oSmarty->fetch( $this->_sOwnerPricealarmTemplate ) );
01343 $this->setFrom( $aParams['email'], "" );
01344 $this->setReplyTo( $aParams['email'], "" );
01345
01346 return $this->send();
01347 }
01348
01360 public function sendPricealarmToCustomer( $sRecipient, $oAlarm, $sBody = null, $sReturnMailBody = null )
01361 {
01362 $this->_clearMailer();
01363
01364 $oShop = $this->_getShop();
01365
01366 if ( $oShop->getId() != $oAlarm->oxpricealarm__oxshopid->value) {
01367 $oShop = oxNew( "oxshop" );
01368 $oShop->load( $oAlarm->oxpricealarm__oxshopid->value);
01369 $this->setShop( $oShop );
01370 }
01371
01372
01373 $this->_setMailParams( $oShop );
01374
01375
01376 $oSmarty = $this->_getSmarty();
01377
01378 $this->setViewData( "product", $oAlarm->getArticle() );
01379 $this->setViewData( "oPriceAlarm", $oAlarm );
01380 $this->setViewData( "bidprice", $oAlarm->getFProposedPrice() );
01381 $this->setViewData( "currency", $oAlarm->getPriceAlarmCurrency() );
01382
01383
01384 $this->_processViewArray();
01385
01386 $this->setRecipient( $sRecipient, $sRecipient );
01387 $this->setSubject( $oShop->oxshops__oxname->value );
01388
01389 if ( $sBody === null ) {
01390 $sBody = $oSmarty->fetch( $this->_sPricealamrCustomerTemplate );
01391 }
01392
01393 $this->setBody( $sBody );
01394
01395 $this->addAddress( $sRecipient, $sRecipient );
01396 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01397
01398 if ( $sReturnMailBody ) {
01399 return $this->getBody();
01400 } else {
01401 return $this->send();
01402 }
01403 }
01404
01416 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01417 {
01418 $sBody = $this->getBody();
01419 if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01420
01421 $oFileUtils = oxRegistry::get("oxUtilsFile");
01422 $blReSetBody = false;
01423
01424
01425 $sDynImageDir = $oFileUtils->normalizeDir( $sDynImageDir );
01426 $sImageDir = $oFileUtils->normalizeDir( $sImageDir );
01427 $sImageDirNoSSL = $oFileUtils->normalizeDir( $sImageDirNoSSL );
01428
01429 if (is_array($matches) && count($matches)) {
01430 $aImageCache = array();
01431 $myUtils = oxRegistry::getUtils();
01432 $myUtilsObject = oxUtilsObject::getInstance();
01433 $oImgGenerator = oxNew( "oxDynImgGenerator" );
01434
01435 foreach ($matches as $aImage) {
01436
01437 $image = $aImage[1];
01438 $sFileName = '';
01439 if ( strpos( $image, $sDynImageDir ) === 0 ) {
01440 $sFileName = $oFileUtils->normalizeDir( $sAbsDynImageDir ) . str_replace( $sDynImageDir, '', $image );
01441 } elseif ( strpos( $image, $sImageDir ) === 0 ) {
01442 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDir, '', $image );
01443 } elseif ( strpos( $image, $sImageDirNoSSL ) === 0 ) {
01444 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDirNoSSL, '', $image );
01445 }
01446
01447 if ( $sFileName && !@is_readable( $sFileName ) ) {
01448 $sFileName = $oImgGenerator->getImagePath( $sFileName );
01449 }
01450
01451 if ( $sFileName ) {
01452 $sCId = '';
01453 if ( isset( $aImageCache[$sFileName] ) && $aImageCache[$sFileName] ) {
01454 $sCId = $aImageCache[$sFileName];
01455 } else {
01456 $sCId = $myUtilsObject->generateUID();
01457 $sMIME = $myUtils->oxMimeContentType($sFileName);
01458 if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01459 if ( $this->addEmbeddedImage( $sFileName, $sCId, "image", "base64", $sMIME ) ) {
01460 $aImageCache[$sFileName] = $sCId;
01461 } else {
01462 $sCId = '';
01463 }
01464 }
01465 }
01466 if ( $sCId && $sCId == $aImageCache[$sFileName] ) {
01467 if ( $sReplTag = str_replace( $image, 'cid:'.$sCId, $aImage[0] ) ) {
01468 $sBody = str_replace($aImage[0], $sReplTag, $sBody );
01469 $blReSetBody = true;
01470 }
01471 }
01472 }
01473 }
01474 }
01475
01476 if ( $blReSetBody ) {
01477 $this->setBody( $sBody );
01478 }
01479 }
01480 }
01481
01489 public function setSubject( $sSubject = null )
01490 {
01491
01492 $sSubject = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sSubject);
01493
01494 $this->set( "Subject", $sSubject );
01495 }
01496
01502 public function getSubject()
01503 {
01504 return $this->Subject;
01505 }
01506
01516 public function setBody( $sBody = null, $blClearSid = true )
01517 {
01518 if ( $blClearSid ) {
01519 $sBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sBody);
01520 }
01521
01522 $this->set( "Body", $sBody );
01523 }
01524
01530 public function getBody()
01531 {
01532 return $this->Body;
01533 }
01534
01544 public function setAltBody( $sAltBody = null, $blClearSid = true )
01545 {
01546 if ( $blClearSid ) {
01547 $sAltBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sAltBody);
01548 }
01549
01550
01551 $sAltBody = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sAltBody);
01552
01553 $this->set( "AltBody", $sAltBody );
01554 }
01555
01561 public function getAltBody()
01562 {
01563 return $this->AltBody;
01564 }
01565
01574 public function setRecipient( $sAddress = null, $sName = null )
01575 {
01576 try {
01577 parent::AddAddress( $sAddress, $sName );
01578
01579
01580 $this->_aRecipients[] = array( $sAddress, $sName );
01581 } catch( Exception $oEx ) {
01582 }
01583 }
01584
01592 public function getRecipient()
01593 {
01594 return $this->_aRecipients;
01595 }
01596
01603 public function clearAllRecipients()
01604 {
01605 $this->_aRecipients = array();
01606 parent::clearAllRecipients();
01607 }
01608
01620 public function setReplyTo( $sEmail = null, $sName = null )
01621 {
01622 if ( !oxRegistry::getUtils()->isValidEmail( $sEmail ) ) {
01623 $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01624 }
01625
01626 $this->_aReplies[] = array( $sEmail, $sName );
01627
01628 try {
01629 parent::addReplyTo( $sEmail, $sName );
01630 } catch( Exception $oEx ) {
01631 }
01632 }
01633
01639 public function getReplyTo()
01640 {
01641 return $this->_aReplies;
01642 }
01643
01649 public function clearReplyTos()
01650 {
01651 $this->_aReplies = array();
01652 parent::clearReplyTos();
01653 }
01654
01663 public function setFrom( $sFromAddress, $sFromName = null )
01664 {
01665
01666
01667
01668 $sFromAddress = substr($sFromAddress, 0, 150);
01669 $sFromName = substr($sFromName, 0, 150);
01670
01671 try {
01672 parent::setFrom( $sFromAddress, $sFromName );
01673 } catch( Exception $oEx ) {
01674 }
01675 }
01676
01682 public function getFrom()
01683 {
01684 return $this->From;
01685 }
01686
01692 public function getFromName()
01693 {
01694 return $this->FromName;
01695 }
01696
01705 public function setCharSet( $sCharSet = null )
01706 {
01707 if ( $sCharSet ) {
01708 $this->_sCharSet = $sCharSet;
01709 } else {
01710 $this->_sCharSet = oxRegistry::getLang()->translateString( "charset" );
01711 }
01712 $this->set( "CharSet", $this->_sCharSet );
01713 }
01714
01722 public function setMailer( $sMailer = null )
01723 {
01724 $this->set( "Mailer", $sMailer );
01725 }
01726
01732 public function getMailer()
01733 {
01734 return $this->Mailer;
01735 }
01736
01744 public function setHost( $sHost = null )
01745 {
01746 $this->set( "Host", $sHost );
01747 }
01748
01754 public function getErrorInfo()
01755 {
01756 return $this->ErrorInfo;
01757 }
01758
01767 public function setMailWordWrap( $iWordWrap = null )
01768 {
01769 $this->set( "WordWrap", $iWordWrap );
01770 }
01771
01779 public function setUseInlineImages( $blUseImages = null )
01780 {
01781 $this->_blInlineImgEmail = $blUseImages;
01782 }
01783
01794 public function addAttachment( $sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01795 {
01796 $this->_aAttachments[] = array( $sAttPath, $sAttFile, $sEncoding, $sType );
01797 $blResult = false;
01798
01799 try {
01800 $blResult = parent::addAttachment( $sAttPath, $sAttFile, $sEncoding, $sType );
01801 } catch( Exception $oEx ) {
01802 }
01803
01804 return $blResult;
01805 }
01806
01818 public function addEmbeddedImage( $sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01819 {
01820 $this->_aAttachments[] = array( $sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid );
01821 return parent::addEmbeddedImage( $sFullPath, $sCid, $sAttFile, $sEncoding, $sType );
01822 }
01823
01829 public function getAttachments()
01830 {
01831 return $this->_aAttachments;
01832 }
01833
01839 public function clearAttachments()
01840 {
01841 $this->_aAttachments = array();
01842 return parent::clearAttachments();
01843 }
01844
01854 public function headerLine($sName, $sValue)
01855 {
01856 if (stripos($sName, 'X-') !== false) {
01857 return;
01858 }
01859 return parent::headerLine($sName, $sValue);
01860 }
01861
01867 protected function _getUseInlineImages()
01868 {
01869 return $this->_blInlineImgEmail;
01870 }
01871
01877 protected function _sendMailErrorMsg()
01878 {
01879
01880 $aRecipients = $this->getRecipient();
01881
01882 $sOwnerMessage = "Error sending eMail(". $this->getSubject().") to: \n\n";
01883
01884 foreach ( $aRecipients as $aEMail ) {
01885 $sOwnerMessage .= $aEMail[0];
01886 $sOwnerMessage .= ( !empty($aEMail[1]) ) ? ' (' . $aEMail[1] . ')' : '';
01887 $sOwnerMessage .= " \n ";
01888 }
01889 $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01890
01891
01892 $oShop = $this->_getShop();
01893
01894 $blRet = @mail( $oShop->oxshops__oxorderemail->value, "eMail problem in shop!", $sOwnerMessage);
01895
01896 return $blRet;
01897 }
01898
01908 protected function _addUserInfoOrderEMail( $oOrder )
01909 {
01910 return $oOrder;
01911 }
01912
01922 protected function _addUserRegisterEmail( $oUser )
01923 {
01924 return $oUser;
01925 }
01926
01936 protected function _addForgotPwdEmail( $oShop )
01937 {
01938 return $oShop;
01939 }
01940
01950 protected function _addNewsletterDbOptInMail( $oUser )
01951 {
01952 return $oUser;
01953 }
01954
01960 protected function _clearMailer()
01961 {
01962 $this->clearAllRecipients();
01963 $this->clearReplyTos();
01964 $this->clearAttachments();
01965
01966
01967 $this->error_count = 0;
01968 $this->ErrorInfo = '';
01969 }
01970
01978 protected function _setMailParams( $oShop = null )
01979 {
01980 $this->_clearMailer();
01981
01982 if ( !$oShop ) {
01983 $oShop = $this->_getShop();
01984 }
01985
01986 $this->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01987 $this->setSmtp( $oShop );
01988 }
01989
01999 protected function _getShop( $iLangId = null, $iShopId = null )
02000 {
02001 if ( $iLangId === null && $iShopId === null ) {
02002 if ( isset( $this->_oShop ) ) {
02003 return $this->_oShop;
02004 } else {
02005 return $this->_oShop = $this->getConfig()->getActiveShop();
02006 }
02007 }
02008
02009 $myConfig = $this->getConfig();
02010
02011 $oShop = oxNew( 'oxShop' );
02012 if ( $iShopId !== null ) {
02013 $oShop->setShopId($iShopId);
02014 }
02015 if ( $iLangId !== null ) {
02016 $oShop->setLanguage($iLangId);
02017 }
02018 $oShop->load($myConfig->getShopId());
02019
02020 return $oShop;
02021 }
02022
02031 protected function _setSmtpAuthInfo( $sUserName = null, $sUserPassword = null )
02032 {
02033 $this->set( "SMTPAuth", true );
02034 $this->set( "Username", $sUserName );
02035 $this->set( "Password", $sUserPassword );
02036 }
02037
02045 protected function _setSmtpDebug( $blDebug = null )
02046 {
02047 $this->set( "SMTPDebug", $blDebug );
02048 }
02049
02055 protected function _setMailerPluginDir()
02056 {
02057 $this->set( "PluginDir", getShopBasePath() . "core/phpmailer/" );
02058 }
02059
02066 protected function _makeOutputProcessing()
02067 {
02068 $oOutput = oxNew( "oxOutput" );
02069 $this->setBody( $oOutput->process($this->getBody(), "oxemail") );
02070 $this->setAltBody( $oOutput->process($this->getAltBody(), "oxemail") );
02071 $oOutput->processEmail( $this );
02072 }
02073
02079 protected function _sendMail()
02080 {
02081 $blResult = false;
02082 try {
02083 $blResult = parent::send();
02084 } catch( Exception $oException ) {
02085 $oEx = oxNew( "oxException" );
02086 $oEx->setMessage($oException->getMessage());
02087 $oEx->debugOut();
02088 if ( $this->getConfig()->getConfigParam( 'iDebug' ) != 0 ) {
02089 throw $oEx;
02090 }
02091 }
02092 return $blResult;
02093 }
02094
02095
02101 protected function _processViewArray()
02102 {
02103 $oSmarty = $this->_getSmarty();
02104 $oOutputProcessor = oxNew( "oxOutput" );
02105
02106
02107 foreach ( $this->_aViewData as $sKey => $sValue ) {
02108 $oSmarty->assign( $sKey, $sValue );
02109 }
02110
02111
02112 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
02113
02114 foreach ( $aNewSmartyArray as $key => $val ) {
02115 $oSmarty->assign( $key, $val );
02116 }
02117 }
02118
02124 public function getCharset()
02125 {
02126 if ( !$this->_sCharSet ) {
02127 return oxRegistry::getLang()->translateString("charset");
02128 } else {
02129 return $this->CharSet;
02130 }
02131 }
02132
02138 public function getShop()
02139 {
02140 return $this->_getShop();
02141 }
02142
02150 public function setShop( $oShop )
02151 {
02152 $this->_oShop = $oShop;
02153 }
02154
02160 public function getViewConfig()
02161 {
02162 return $this->getConfig()->getActiveView()->getViewConfig();
02163 }
02164
02170 public function getView()
02171 {
02172 return $this->getConfig()->getActiveView();
02173 }
02174
02180 public function getCurrency()
02181 {
02182 $oConfig = oxRegistry::getConfig();
02183
02184 return $oConfig->getActShopCurrencyObject();
02185 }
02186
02195 public function setViewData( $sKey, $sValue )
02196 {
02197 $this->_aViewData[$sKey] = $sValue;
02198 }
02199
02205 public function getViewData()
02206 {
02207 return $this->_aViewData;
02208 }
02209
02217 public function getViewDataItem( $sKey )
02218 {
02219 if ( isset($this->_aViewData[$sKey]) ) {
02220 return $this->_aViewData;
02221 }
02222 }
02223
02231 public function setUser( $oUser)
02232 {
02233 $this->_aViewData["oUser"] = $oUser;
02234 }
02235
02241 public function getUser()
02242 {
02243 return $this->_aViewData["oUser"];
02244 }
02245
02253 public function getOrderFileList( $sOrderId )
02254 {
02255 $oOrderList = oxNew('oxOrderFileList');
02256 $oOrderList->loadOrderFiles( $sOrderId );
02257
02258 if ( count($oOrderList) > 0 ) {
02259 return $oOrderList;
02260 }
02261
02262 return false;
02263 }
02264
02265 }