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 $blSmtpSendFailed = true;
00336 $this->setMailer( 'mail' );
00337 $blRet = $this->_sendMail();
00338 }
00339 } else {
00340
00341 $this->setMailer( 'mail' );
00342 $blRet = $this->_sendMail();
00343 }
00344
00345 if ( !$blRet || $blSmtpSendFailed ) {
00346
00347 $this->_sendMailErrorMsg();
00348 }
00349
00350 return $blRet;
00351 }
00352
00361 protected function _setSmtpProtocol($sUrl)
00362 {
00363 $sProtocol = '';
00364 $sSmtpHost = $sUrl;
00365 $aMatch = array();
00366 if ( getStr()->preg_match('@^([0-9a-z]+://)?(.*)$@i', $sUrl, $aMatch ) ) {
00367 if ($aMatch[1]) {
00368 if (($aMatch[1] == 'ssl://') || ($aMatch[1] == 'tls://')) {
00369 $this->set( "SMTPSecure", substr($aMatch[1], 0, 3) );
00370 } else {
00371 $sProtocol = $aMatch[1];
00372 }
00373 }
00374 $sSmtpHost = $aMatch[2];
00375 }
00376
00377 return $sProtocol.$sSmtpHost;
00378 }
00379
00387 public function setSmtp( $oShop = null )
00388 {
00389 $myConfig = $this->getConfig();
00390 $oShop = ( $oShop ) ? $oShop : $this->_getShop();
00391
00392 $sSmtpUrl = $this->_setSmtpProtocol($oShop->oxshops__oxsmtp->value);
00393
00394 if ( !$this->_isValidSmtpHost( $sSmtpUrl ) ) {
00395 $this->setMailer( "mail" );
00396 return;
00397 }
00398
00399 $this->setHost( $sSmtpUrl );
00400 $this->setMailer( "smtp" );
00401
00402 if ( $oShop->oxshops__oxsmtpuser->value ) {
00403 $this->_setSmtpAuthInfo( $oShop->oxshops__oxsmtpuser->value, $oShop->oxshops__oxsmtppwd->value );
00404 }
00405
00406 if ( $myConfig->getConfigParam( 'iDebug' ) == 6 ) {
00407 $this->_setSmtpDebug( true );
00408 }
00409 }
00410
00418 protected function _isValidSmtpHost( $sSmtpHost )
00419 {
00420 $blIsSmtp = false;
00421 if ( $sSmtpHost ) {
00422 $sSmtpPort = $this->SMTP_PORT;
00423 $aMatch = array();
00424 if ( getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $sSmtpHost, $aMatch)) {
00425 $sSmtpHost = $aMatch[1];
00426 $sSmtpPort = (int)$aMatch[3];
00427 if (!$sSmtpPort) {
00428 $sSmtpPort = $this->SMTP_PORT;
00429 }
00430 }
00431 if ( $blIsSmtp = (bool) ( $rHandle = @fsockopen( $sSmtpHost, $sSmtpPort, $iErrNo, $sErrStr, 30 )) ) {
00432
00433 fclose( $rHandle );
00434 }
00435 }
00436
00437 return $blIsSmtp;
00438 }
00439
00449 public function sendOrderEmailToUser( $oOrder, $sSubject = null )
00450 {
00451 $myConfig = $this->getConfig();
00452
00453
00454 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00455
00456
00457 $oShop = $this->_getShop();
00458 $this->_setMailParams( $oShop );
00459
00460
00461
00462 $oOrder->oDelSet = $oOrder->getDelSet();
00463
00464 $oUser = $oOrder->getOrderUser();
00465
00466 $oSmarty = $this->_getSmarty();
00467 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00468 $oSmarty->assign( "order", $oOrder);
00469 $oSmarty->assign( "shop", $oShop );
00470 $oSmarty->assign( "oViewConf", $oShop );
00471 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00472 $oSmarty->assign( "user", $oUser );
00473 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00474 $oSmarty->assign( "basket", $oOrder->getBasket() );
00475 $oSmarty->assign( "payment", $oOrder->getPayment() );
00476 if ( $oUser ) {
00477 $oSmarty->assign( "reviewuserhash", $oUser->getReviewUserHash( $oUser->getId() ) );
00478 }
00479 $oSmarty->assign( "paymentinfo", $myConfig->getActiveShop() );
00480
00481
00482 $oSmarty->assign( "iswishlist", true );
00483 $oSmarty->assign( "isreview", true );
00484
00485 if ( $aVoucherList = $oOrder->getVoucherList() ) {
00486 $oSmarty->assign( "vouchers", $aVoucherList );
00487 }
00488
00489 $oOutputProcessor = oxNew( "oxoutput" );
00490 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00491
00492 foreach ( $aNewSmartyArray as $key => $val ) {
00493 $oSmarty->assign( $key, $val );
00494 }
00495
00496 $this->setBody( $oSmarty->fetch( $this->_sOrderUserTemplate ) );
00497 $this->setAltBody( $oSmarty->fetch( $this->_sOrderUserPlainTemplate ) );
00498
00499
00500 if ( $sSubject === null ) {
00501 if ( $oSmarty->template_exists( $this->_sOrderUserSubjectTemplate) ) {
00502 $sSubject = $oSmarty->fetch( $this->_sOrderUserSubjectTemplate );
00503 } else {
00504 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00505 }
00506 }
00507
00508 $this->setSubject( $sSubject );
00509
00510 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00511
00512 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00513 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00514
00515 $blSuccess = $this->send();
00516
00517 return $blSuccess;
00518 }
00519
00529 public function sendOrderEmailToOwner( $oOrder, $sSubject = null )
00530 {
00531 $myConfig = $this->getConfig();
00532
00533 $oShop = $this->_getShop();
00534
00535
00536 $this->_clearMailer();
00537
00538
00539 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00540
00541
00542 $sFullName = $oOrder->getOrderUser()->oxuser__oxfname->getRawValue() . " " . $oOrder->getOrderUser()->oxuser__oxlname->getRawValue();
00543 $this->setFrom( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00544
00545 $oLang = oxLang::getInstance();
00546 $iOrderLang = $oLang->getObjectTplLanguage();
00547
00548
00549
00550 if ( $oShop->getLanguage() != $iOrderLang ) {
00551 $oShop = $this->_getShop( $iOrderLang );
00552 }
00553
00554 $this->setSmtp( $oShop );
00555
00556
00557 $oSmarty = $this->_getSmarty();
00558 $oSmarty->assign( "charset", $oLang->translateString("charset"));
00559 $oSmarty->assign( "order", $oOrder );
00560 $oSmarty->assign( "shop", $oShop );
00561 $oSmarty->assign( "oViewConf", $oShop );
00562 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00563 $oSmarty->assign( "user", $oOrder->getOrderUser() );
00564 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00565 $oSmarty->assign( "basket", $oOrder->getBasket() );
00566 $oSmarty->assign( "payment", $oOrder->getPayment() );
00567
00568
00569 $oSmarty->assign( "iswishlist", true);
00570
00571 if( $oOrder->getVoucherList() )
00572 $oSmarty->assign( "vouchers", $oOrder->getVoucherList() );
00573
00574 $oOutputProcessor = oxNew( "oxoutput" );
00575 $aNewSmartyArray = $oOutputProcessor->processViewArray($oSmarty->get_template_vars(), "oxemail");
00576 foreach ($aNewSmartyArray as $key => $val)
00577 $oSmarty->assign( $key, $val );
00578
00579 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerTemplate, false ) ) );
00580 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerPlainTemplate, false ) ) );
00581
00582
00583
00584 if ( $sSubject === null ) {
00585 if ( $oSmarty->template_exists( $this->_sOrderOwnerSubjectTemplate) ) {
00586 $sSubject = $oSmarty->fetch( $this->_sOrderOwnerSubjectTemplate );
00587 } else {
00588 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00589 }
00590 }
00591
00592 $this->setSubject( $sSubject );
00593 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oLang->translateString("order") );
00594
00595 if ( $oOrder->getOrderUser()->oxuser__oxusername->value != "admin" )
00596 $this->setReplyTo( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00597
00598 $blSuccess = $this->send();
00599
00600
00601 $oRemark = oxNew( "oxremark" );
00602 $oRemark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
00603 $oRemark->oxremark__oxparentid = new oxField($oOrder->getOrderUser()->getId(), oxField::T_RAW);
00604 $oRemark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
00605 $oRemark->save();
00606
00607
00608 if ( $myConfig->getConfigParam( 'iDebug' ) == 6) {
00609 oxUtils::getInstance()->showMessageAndExit( "" );
00610 }
00611
00612 return $blSuccess;
00613 }
00614
00624 public function sendRegisterConfirmEmail( $oUser, $sSubject = null )
00625 {
00626
00627 $oSmarty = $this->_getSmarty();
00628 $oSmarty->assign( "contentident", "oxregisteraltemail" );
00629 $oSmarty->assign( "contentplainident", "oxregisterplainaltemail" );
00630
00631
00632 return $this->sendRegisterEmail( $oUser, $sSubject );
00633 }
00634
00644 public function sendRegisterEmail( $oUser, $sSubject = null )
00645 {
00646
00647 $oUser = $this->_addUserRegisterEmail( $oUser );
00648
00649
00650 $oShop = $this->_getShop();
00651
00652
00653 $this->_setMailParams( $oShop );
00654
00655
00656 $oSmarty = $this->_getSmarty();
00657 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00658 $oSmarty->assign( "shop", $oShop );
00659 $oSmarty->assign( "oViewConf", $oShop );
00660 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00661 $oSmarty->assign( "user", $oUser );
00662
00663 $oOutputProcessor = oxNew( "oxoutput" );
00664 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00665
00666 foreach ( $aNewSmartyArray as $key => $val ) {
00667 $oSmarty->assign( $key, $val );
00668 }
00669
00670 $this->setBody( $oSmarty->fetch( $this->_sRegisterTemplate ) );
00671 $this->setAltBody( $oSmarty->fetch( $this->_sRegisterTemplatePlain ) );
00672
00673 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue() );
00674
00675 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00676
00677 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00678 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00679
00680 return $this->send();
00681 }
00682
00692 public function sendForgotPwdEmail( $sEmailAddress, $sSubject = null )
00693 {
00694 $myConfig = $this->getConfig();
00695 $oDb = oxDb::getDb();
00696
00697
00698 $oShop = $this->_getShop();
00699
00700
00701 $oShop = $this->_addForgotPwdEmail( $oShop);
00702
00703
00704 $this->_setMailParams( $oShop );
00705
00706
00707 $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sEmailAddress )." and oxuser.oxpassword != ''";
00708 $sOrder = "";
00709 if ( $myConfig->getConfigParam( 'blMallUsers' )) {
00710 $sOrder = "order by oxshopid = '".$oShop->getId()."' desc";
00711 } else {
00712 $sWhere .= " and oxshopid = '".$oShop->getId()."'";
00713 }
00714
00715 $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00716 if ( ( $sOxId = $oDb->getOne( $sSelect ) ) ) {
00717
00718 $oUser = oxNew( 'oxuser' );
00719 if ( $oUser->load($sOxId) ) {
00720
00721 $oSmarty = $this->_getSmarty();
00722 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00723 $oSmarty->assign( "shop", $oShop );
00724 $oSmarty->assign( "oViewConf", $oShop );
00725 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00726 $oSmarty->assign( "user", $oUser );
00727
00728 $oOutputProcessor = oxNew( "oxoutput" );
00729 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00730
00731 foreach ( $aNewSmartyArray as $key => $val ) {
00732 $oSmarty->assign($key, $val);
00733 }
00734
00735 $this->setBody( $oSmarty->fetch( $this->_sForgotPwdTemplate ) );
00736 $this->setAltBody( $oSmarty->fetch( $this->_sForgotPwdTemplatePlain ) );
00737
00738
00739 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue() );
00740
00741 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00742
00743 $this->setRecipient( $sEmailAddress, $sFullName );
00744 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00745
00746 return $this->send();
00747 }
00748 }
00749
00750 return false;
00751 }
00752
00763 public function sendContactMail( $sEmailAddress = null, $sSubject = null, $sMessage = null )
00764 {
00765
00766
00767 $oShop = $this->_getShop();
00768
00769
00770 $this->_setMailParams( $oShop );
00771
00772 $this->setBody( $sMessage );
00773 $this->setSubject( $sSubject );
00774
00775 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00776 $this->setFrom( $sEmailAddress, "" );
00777 $this->setReplyTo( $sEmailAddress, "" );
00778
00779 return $this->send();
00780 }
00781
00791 public function sendNewsletterDbOptInMail( $oUser, $sSubject = null )
00792 {
00793 $oLang = oxLang::getInstance();
00794
00795
00796 $oUser = $this->_addNewsletterDbOptInMail( $oUser );
00797
00798
00799 $oShop = $this->_getShop();
00800
00801
00802 $this->_setMailParams( $oShop );
00803
00804
00805 $oSmarty = $this->_getSmarty();
00806 $oSmarty->assign( "charset", $oLang->translateString("charset"));
00807 $oSmarty->assign( "shop", $oShop );
00808 $oSmarty->assign( "oViewConf", $oShop );
00809 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00810 $oSmarty->assign( "subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value) );
00811 $oSmarty->assign( "user", $oUser );
00812
00813 $oOutputProcessor = oxNew( "oxoutput" );
00814 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00815 foreach ( $aNewSmartyArray as $key => $val ) {
00816 $oSmarty->assign( $key, $val );
00817 }
00818
00819 $this->setBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplate ) );
00820 $this->setAltBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplatePlain ) );
00821 $this->setSubject( ( $sSubject !== null ) ? $sSubject : oxLang::getInstance()->translateString("EMAIL_NEWSLETTERDBOPTINMAIL_SUBJECT") . " " . $oShop->oxshops__oxname->getRawValue() );
00822
00823 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00824
00825 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00826 $this->setFrom( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00827 $this->setReplyTo( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00828
00829 return $this->send();
00830 }
00831
00839 protected function _getNewsSubsLink( $sId )
00840 {
00841 $myConfig = $this->getConfig();
00842 $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00843
00844 $sUrl = $myConfig->getShopHomeURL().'cl=newsletter&fnc=addme&uid='.$sId;
00845 $sUrl.= ( $iActShopLang ) ? '&lang='.$iActShopLang : "";
00846 return $sUrl;
00847 }
00848
00859 public function sendNewsletterMail( $oNewsLetter, $oUser, $sSubject = null )
00860 {
00861
00862 $oShop = $this->_getShop();
00863
00864
00865 $this->_setMailParams( $oShop );
00866
00867 $sBody = $oNewsLetter->getHtmlText();
00868
00869 if ( !empty($sBody) ) {
00870 $this->setBody( $sBody );
00871 $this->setAltBody( $oNewsLetter->getPlainText() );
00872 } else {
00873 $this->isHtml( false );
00874 $this->setBody( $oNewsLetter->getPlainText() );
00875 }
00876
00877 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue() );
00878
00879 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00880 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00881 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00882
00883 return $this->send();
00884 }
00885
00895 public function sendSuggestMail( $oParams, $oProduct )
00896 {
00897 $myConfig = $this->getConfig();
00898
00899
00900 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00901
00902
00903 $oShop = $this->_getShop( $iCurrLang );
00904
00905
00906 if ( $oProduct->getLanguage() != $iCurrLang ) {
00907 $oProduct->setLanguage( $iCurrLang );
00908 $oProduct->load( $oProduct->getId() );
00909 }
00910
00911
00912 $this->setFrom( $oParams->send_email, $oParams->send_name );
00913 $this->setSMTP();
00914
00915
00916 $oSmarty = $this->_getSmarty();
00917 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00918 $oSmarty->assign( "shop", $oShop );
00919 $oSmarty->assign( "oViewConf", $oShop );
00920 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00921 $oSmarty->assign( "userinfo", $oParams );
00922 $oSmarty->assign( "product", $oProduct );
00923
00924 $sArticleUrl = $oProduct->getLink();
00925
00926
00927 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00928 $sArticleUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sArticleUrl );
00929 $sArticleUrl .= "su=" . $oActiveUser->getId();
00930 }
00931
00932 $oSmarty->assign( "sArticleUrl", $sArticleUrl );
00933
00934 $oOutputProcessor = oxNew( "oxoutput" );
00935 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00936
00937 foreach ( $aNewSmartyArray as $key => $val ) {
00938 $oSmarty->assign( $key, $val );
00939 }
00940
00941 $this->setBody( $oSmarty->fetch( $this->_sSuggestTemplate ) );
00942 $this->setAltBody( $oSmarty->fetch( $this->_sSuggestTemplatePlain ) );
00943 $this->setSubject( $oParams->send_subject );
00944
00945 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
00946 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00947
00948 return $this->send();
00949 }
00950
00959 public function sendInviteMail( $oParams )
00960 {
00961 $myConfig = $this->getConfig();
00962
00963
00964 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00965
00966
00967 $oShop = $this->_getShop( $iCurrLang );
00968
00969
00970 $this->setFrom( $oParams->send_email, $oParams->send_name );
00971 $this->setSMTP();
00972
00973
00974 $oSmarty = oxUtilsView::getInstance()->getSmarty();
00975 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00976 $oSmarty->assign( "shop", $oShop );
00977 $oSmarty->assign( "oViewConf", $oShop );
00978 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00979 $oSmarty->assign( "userinfo", $oParams );
00980 $oSmarty->assign( "sShopUrl", $myConfig->getShopCurrentUrl() );
00981
00982 $sHomeUrl = $oShop->getHomeLink();
00983
00984
00985 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00986 $sHomeUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sHomeUrl );
00987 $sHomeUrl .= "su=" . $oActiveUser->getId();
00988 }
00989
00990 $oSmarty->assign( "sHomeUrl", $sHomeUrl );
00991
00992 $oOutputProcessor = oxNew( "oxoutput" );
00993 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00994
00995 foreach ( $aNewSmartyArray as $key => $val ) {
00996 $oSmarty->assign( $key, $val );
00997 }
00998
00999 $this->setBody( $oSmarty->fetch( $this->_sInviteTemplate ) );
01000
01001 $this->setAltBody( $oSmarty->fetch( $this->_sInviteTemplatePlain ) );
01002 $this->setSubject( $oParams->send_subject );
01003
01004 if ( is_array($oParams->rec_email) && count($oParams->rec_email) > 0 ) {
01005 foreach ( $oParams->rec_email as $sEmail ) {
01006 if ( !empty( $sEmail ) ) {
01007 $this->setRecipient( $sEmail );
01008 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01009 $this->send();
01010 $this->clearAllRecipients();
01011 }
01012 }
01013
01014 return true;
01015 }
01016
01017 return false;
01018 }
01019
01029 public function sendSendedNowMail( $oOrder, $sSubject = null )
01030 {
01031 $myConfig = $this->getConfig();
01032
01033 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01034
01035
01036 $oShop = $this->_getShop( $iOrderLang );
01037
01038
01039 $this->_setMailParams( $oShop );
01040
01041
01042
01043
01044
01045 $oLang = oxLang::getInstance();
01046 $oSmarty = $this->_getSmarty();
01047 $oSmarty->assign( "charset", $oLang->translateString("charset"));
01048 $oSmarty->assign( "shop", $oShop );
01049 $oSmarty->assign( "oViewConf", $oShop );
01050 $oSmarty->assign( "oView", $myConfig->getActiveView() );
01051 $oSmarty->assign( "order", $oOrder );
01052 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
01053
01054
01055 $oSmarty->assign( "isreview", true);
01056 $oUser = oxNew( 'oxuser' );
01057 $oSmarty->assign( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01058
01059 $oOutputProcessor = oxNew( "oxoutput" );
01060 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
01061
01062 foreach ( $aNewSmartyArray as $key => $val ) {
01063 $oSmarty->assign( $key, $val );
01064 }
01065
01066
01067 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01068
01069 $iOldTplLang = $oLang->getTplLanguage();
01070 $iOldBaseLang = $oLang->getTplLanguage();
01071 $oLang->setTplLanguage( $iOrderLang );
01072 $oLang->setBaseLanguage( $iOrderLang );
01073
01074 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01075
01076 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplate, false ) ) );
01077 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplatePlain, false ) ) );
01078 $oLang->setTplLanguage( $iOldTplLang );
01079 $oLang->setBaseLanguage( $iOldBaseLang );
01080
01081 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01082
01083
01084 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue() );
01085
01086 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01087
01088 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01089 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01090 return $this->send();
01091 }
01092
01107 public function sendBackupMail( $aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError )
01108 {
01109
01110
01111
01112
01113
01114
01115
01116 $oShop = $this->_getShop();
01117
01118
01119 $this->_setMailParams( $oShop );
01120
01121 $this->setBody( $sMessage );
01122 $this->setSubject( $sSubject );
01123
01124 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
01125 $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
01126
01127 $this->setFrom( $sEmailAddress, "" );
01128 $this->setReplyTo( $sEmailAddress, "" );
01129
01130
01131 $blAttashSucc = true;
01132 $sAttPath = oxUtilsFile::getInstance()->normalizeDir($sAttPath);
01133 foreach ( $aAttFiles as $iNum => $sAttFile ) {
01134 if ( file_exists($sAttPath . $sAttFile) && is_file($sAttPath . $sAttFile) ) {
01135 $blAttashSucc = $this->addAttachment( $sAttPath, $sAttFile );
01136 } else {
01137 $blAttashSucc = false;
01138 $aError[] = array( 5, $sAttFile );
01139 }
01140 }
01141
01142 if ( !$blAttashSucc ) {
01143 $aError[] = array( 4, "" );
01144 $this->clearAttachments();
01145 return false;
01146 }
01147
01148 $aStatus[] = 3;
01149 $blSend = $this->send();
01150 $this->clearAttachments();
01151
01152 return $blSend;
01153 }
01154
01165 public function sendEmail( $sTo, $sSubject, $sBody )
01166 {
01167
01168 $this->_setMailParams();
01169
01170 if ( is_array($sTo) ) {
01171 foreach ($sTo as $sAddress) {
01172 $this->setRecipient( $sAddress, "" );
01173 $this->setReplyTo( $sAddress, "" );
01174 }
01175 } else {
01176 $this->setRecipient( $sTo, "" );
01177 $this->setReplyTo( $sTo, "" );
01178 }
01179
01180
01181 $this->isHtml( false );
01182
01183 $this->setSubject( $sSubject );
01184 $this->setBody( $sBody );
01185
01186 return $this->send();
01187 }
01188
01197 public function sendStockReminder( $aBasketContents, $sSubject = null )
01198 {
01199 $blSend = false;
01200
01201 $oArticleList = oxNew( "oxarticlelist" );
01202 $oArticleList->loadStockRemindProducts( $aBasketContents );
01203
01204
01205 if ( $oArticleList->count() ) {
01206 $oShop = $this->_getShop();
01207
01208
01209 $this->_setMailParams( $oShop );
01210 $oLang = oxLang::getInstance();
01211
01212 $oSmarty = $this->_getSmarty();
01213 $oSmarty->assign( "charset", $oLang->translateString( "charset" ) );
01214 $oSmarty->assign( "shop", $oShop );
01215 $oSmarty->assign( "oViewConf", $oShop );
01216 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01217 $oSmarty->assign( "articles", $oArticleList );
01218
01219 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01220 $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01221 $this->setBody( $oSmarty->fetch( $this->getConfig()->getTemplatePath( $this->_sReminderMailTemplate, false ) ) );
01222 $this->setAltBody( "" );
01223 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_STOCKREMINDER_SUBJECT' ) );
01224
01225 $blSend = $this->send();
01226 }
01227
01228 return $blSend;
01229 }
01230
01239 public function sendWishlistMail( $oParams )
01240 {
01241 $myConfig = $this->getConfig();
01242
01243 $this->_clearMailer();
01244
01245
01246 $oShop = $this->_getShop();
01247
01248
01249 $this->setFrom( $oParams->send_email, $oParams->send_name );
01250 $this->setSMTP();
01251
01252
01253 $oSmarty = $this->_getSmarty();
01254 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
01255 $oSmarty->assign( "shop", $oShop );
01256 $oSmarty->assign( "oViewConf", $oShop );
01257 $oSmarty->assign( "oView", $myConfig->getActiveView() );
01258 $oSmarty->assign( "userinfo", $oParams );
01259
01260 $this->setBody( $oSmarty->fetch( $this->_sWishListTemplate ) );
01261 $this->setAltBody( $oSmarty->fetch( $this->_sWishListTemplatePlain ) );
01262 $this->setSubject( $oParams->send_subject );
01263
01264 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
01265 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01266
01267 return $this->send();
01268 }
01269
01280 public function sendPriceAlarmNotification( $aParams, $oAlarm, $sSubject = null )
01281 {
01282 $this->_clearMailer();
01283 $oShop = $this->_getShop();
01284
01285
01286 $this->_setMailParams( $oShop );
01287
01288 $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01289
01290 $oArticle = oxNew( "oxarticle" );
01291 $oArticle->setSkipAbPrice( true );
01292 $oArticle->loadInLang( $iAlarmLang, $aParams['aid'] );
01293
01294 $oCur = $this->getConfig()->getActShopCurrencyObject();
01295 $oLang = oxLang::getInstance();
01296
01297
01298 $oSmarty = $this->_getSmarty();
01299 $oSmarty->assign( "shop", $oShop );
01300 $oSmarty->assign( "oViewConf", $oShop );
01301 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01302 $oSmarty->assign( "product", $oArticle );
01303 $oSmarty->assign( "email", $aParams['email']);
01304 $oSmarty->assign( "bidprice", $oLang->formatCurrency( $oAlarm->oxpricealarm__oxprice->value, $oCur ) );
01305 $oSmarty->assign( "currency", $oCur );
01306
01307 $this->setRecipient( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01308 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_PRICEALARM_OWNER_SUBJECT', $iAlarmLang ) . " " . $oArticle->oxarticles__oxtitle->getRawValue() );
01309 $this->setBody( $oSmarty->fetch( $this->_sOwnerPricealarmTemplate ) );
01310 $this->setFrom( $aParams['email'], "" );
01311 $this->setReplyTo( $aParams['email'], "" );
01312
01313 return $this->send();
01314 }
01315
01327 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01328 {
01329 $sBody = $this->getBody();
01330 if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01331
01332 $oFileUtils = oxUtilsFile::getInstance();
01333 $blReSetBody = false;
01334
01335
01336 $sDynImageDir = $oFileUtils->normalizeDir( $sDynImageDir );
01337 $sImageDir = $oFileUtils->normalizeDir( $sImageDir );
01338 $sImageDirNoSSL = $oFileUtils->normalizeDir( $sImageDirNoSSL );
01339
01340 if (is_array($matches) && count($matches)) {
01341 $aImageCache = array();
01342 $myUtils = oxUtils::getInstance();
01343 $myUtilsObject = oxUtilsObject::getInstance();
01344
01345 foreach ($matches as $aImage) {
01346
01347 $image = $aImage[1];
01348 $sFileName = '';
01349 if ( strpos( $image, $sDynImageDir ) === 0 ) {
01350 $sFileName = $oFileUtils->normalizeDir( $sAbsDynImageDir ) . str_replace( $sDynImageDir, '', $image );
01351 } elseif ( strpos( $image, $sImageDir ) === 0 ) {
01352 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDir, '', $image );
01353 } elseif ( strpos( $image, $sImageDirNoSSL ) === 0 ) {
01354 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDirNoSSL, '', $image );
01355 }
01356
01357 if ($sFileName && @is_file($sFileName)) {
01358 $sCId = '';
01359 if ( isset( $aImageCache[$sFileName] ) && $aImageCache[$sFileName] ) {
01360 $sCId = $aImageCache[$sFileName];
01361 } else {
01362 $sCId = $myUtilsObject->generateUID();
01363 $sMIME = $myUtils->oxMimeContentType($sFileName);
01364 if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01365 if ( $this->addEmbeddedImage( $sFileName, $sCId, "image", "base64", $sMIME ) ) {
01366 $aImageCache[$sFileName] = $sCId;
01367 } else {
01368 $sCId = '';
01369 }
01370 }
01371 }
01372 if ( $sCId && $sCId == $aImageCache[$sFileName] ) {
01373 if ( $sReplTag = str_replace( $image, 'cid:'.$sCId, $aImage[0] ) ) {
01374 $sBody = str_replace($aImage[0], $sReplTag, $sBody );
01375 $blReSetBody = true;
01376 }
01377 }
01378 }
01379 }
01380 }
01381
01382 if ( $blReSetBody ) {
01383 $this->setBody( $sBody );
01384 }
01385 }
01386 }
01387
01395 public function setSubject( $sSubject = null )
01396 {
01397
01398 $sSubject = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sSubject);
01399
01400 $this->set( "Subject", $sSubject );
01401 }
01402
01408 public function getSubject()
01409 {
01410 return $this->Subject;
01411 }
01412
01422 public function setBody( $sBody = null, $blClearSid = true )
01423 {
01424 if ( $blClearSid ) {
01425 $sBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sBody);
01426 }
01427
01428 $this->set( "Body", $sBody );
01429 }
01430
01436 public function getBody()
01437 {
01438 return $this->Body;
01439 }
01440
01450 public function setAltBody( $sAltBody = null, $blClearSid = true )
01451 {
01452 if ( $blClearSid ) {
01453 $sAltBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sAltBody);
01454 }
01455
01456
01457 $sAltBody = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sAltBody);
01458
01459 $this->set( "AltBody", $sAltBody );
01460 }
01461
01467 public function getAltBody()
01468 {
01469 return $this->AltBody;
01470 }
01471
01480 public function setRecipient( $sAddress = null, $sName = null )
01481 {
01482 try {
01483 parent::AddAddress( $sAddress, $sName );
01484
01485
01486 $this->_aRecipients[] = array( $sAddress, $sName );
01487 } catch( Exception $oEx ) {
01488 }
01489 }
01490
01498 public function getRecipient()
01499 {
01500 return $this->_aRecipients;
01501 }
01502
01509 public function clearAllRecipients()
01510 {
01511 $this->_aRecipients = array();
01512 parent::clearAllRecipients();
01513 }
01514
01526 public function setReplyTo( $sEmail = null, $sName = null )
01527 {
01528 if ( !oxUtils::getInstance()->isValidEmail( $sEmail ) ) {
01529 $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01530 }
01531
01532 $this->_aReplies[] = array( $sEmail, $sName );
01533
01534 try {
01535 parent::addReplyTo( $sEmail, $sName );
01536 } catch( Exception $oEx ) {
01537 }
01538 }
01539
01545 public function getReplyTo()
01546 {
01547 return $this->_aReplies;
01548 }
01549
01555 public function clearReplyTos()
01556 {
01557 $this->_aReplies = array();
01558 parent::clearReplyTos();
01559 }
01560
01569 public function setFrom( $sFromAdress, $sFromName = null )
01570 {
01571
01572
01573
01574 $sFromAdress = substr($sFromAdress, 0, 150);
01575 $sFromName = substr($sFromName, 0, 150);
01576
01577 try {
01578 parent::setFrom( $sFromAdress, $sFromName );
01579 } catch( Exception $oEx ) {
01580 }
01581 }
01582
01588 public function getFrom()
01589 {
01590 return $this->From;
01591 }
01592
01598 public function getFromName()
01599 {
01600 return $this->FromName;
01601 }
01602
01611 public function setCharSet( $sCharSet = null )
01612 {
01613 $this->set( "CharSet", $sCharSet ? $sCharSet : oxLang::getInstance()->translateString( "charset" ) );
01614 }
01615
01621 public function getCharSet()
01622 {
01623 return $this->CharSet;
01624 }
01625
01633 public function setMailer( $sMailer = null )
01634 {
01635 $this->set( "Mailer", $sMailer );
01636 }
01637
01643 public function getMailer()
01644 {
01645 return $this->Mailer;
01646 }
01647
01655 public function setHost( $sHost = null )
01656 {
01657 $this->set( "Host", $sHost );
01658 }
01659
01665 public function getErrorInfo()
01666 {
01667 return $this->ErrorInfo;
01668 }
01669
01678 public function setMailWordWrap( $iWordWrap = null )
01679 {
01680 $this->set( "WordWrap", $iWordWrap );
01681 }
01682
01690 public function setUseInlineImages( $blUseImages = null )
01691 {
01692 $this->_blInlineImgEmail = $blUseImages;
01693 }
01694
01705 public function addAttachment( $sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01706 {
01707 $sFullPath = $sAttPath . $sAttFile;
01708
01709 $this->_aAttachments[] = array( $sFullPath, $sAttFile, $sEncoding, $sType );
01710 $blResult = false;
01711
01712 try {
01713 $blResult = parent::addAttachment( $sFullPath, $sAttFile, $sEncoding, $sType );
01714 } catch( Exception $oEx ) {
01715 }
01716
01717 return $blResult;
01718 }
01719
01731 public function addEmbeddedImage( $sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01732 {
01733 $this->_aAttachments[] = array( $sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid );
01734 return parent::addEmbeddedImage( $sFullPath, $sCid, $sAttFile, $sEncoding, $sType );
01735 }
01736
01742 public function getAttachments()
01743 {
01744 return $this->_aAttachments;
01745 }
01746
01752 public function clearAttachments()
01753 {
01754 $this->_aAttachments = array();
01755 return parent::clearAttachments();
01756 }
01757
01767 public function headerLine($sName, $sValue)
01768 {
01769 if (stripos($sName, 'X-') !== false) {
01770 return;
01771 }
01772 return parent::headerLine($sName, $sValue);
01773 }
01774
01780 protected function _getUseInlineImages()
01781 {
01782 return $this->_blInlineImgEmail;
01783 }
01784
01790 protected function _sendMailErrorMsg()
01791 {
01792
01793 $sToAdress = "";
01794 $sToName = "";
01795
01796 $aRecipients = $this->getRecipient();
01797
01798 $sOwnerMessage = "Error sending eMail(". $this->getSubject().") to: \n\n";
01799
01800 foreach ( $aRecipients as $aEMail ) {
01801 $sOwnerMessage .= $aEMail[0];
01802 $sOwnerMessage .= ( !empty($aEMail[1]) ) ? ' (' . $aEMail[1] . ')' : '';
01803 $sOwnerMessage .= " \n ";
01804 }
01805 $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01806
01807
01808 $oShop = $this->_getShop();
01809
01810 $blRet = @mail( $oShop->oxshops__oxorderemail->value, "eMail problem in shop !", $sOwnerMessage);
01811
01812 return $blRet;
01813 }
01814
01824 protected function _addUserInfoOrderEMail( $oOrder )
01825 {
01826 return $oOrder;
01827 }
01828
01838 protected function _addUserRegisterEmail( $oUser )
01839 {
01840 return $oUser;
01841 }
01842
01852 protected function _addForgotPwdEmail( $oShop )
01853 {
01854 return $oShop;
01855 }
01856
01866 protected function _addNewsletterDbOptInMail( $oUser )
01867 {
01868 return $oUser;
01869 }
01870
01876 protected function _clearMailer()
01877 {
01878 $this->clearAllRecipients();
01879 $this->clearReplyTos();
01880 $this->clearAttachments();
01881
01882
01883 $this->error_count = 0;
01884 $this->ErrorInfo = '';
01885 }
01886
01894 protected function _setMailParams( $oShop = null )
01895 {
01896 $this->_clearMailer();
01897
01898 if ( !$oShop ) {
01899 $oShop = $this->_getShop();
01900 }
01901
01902 $this->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01903 $this->setSmtp( $oShop );
01904 }
01905
01914 protected function _getShop( $iLangId = null )
01915 {
01916 $myConfig = $this->getConfig();
01917 if ( $iLangId === null ) {
01918 $iLangId = $myConfig->getActiveShop()->getLanguage();
01919 }
01920 $iLangId = oxLang::getInstance()->validateLanguage( $iLangId );
01921
01922 if ( !isset( $this->_aShops[$iLangId] ) ) {
01923 $oShop = oxNew( 'oxshop' );
01924 $oShop->loadInLang( $iLangId, $myConfig->getShopId() );
01925 $this->_aShops[$iLangId] = $myConfig->getActiveView()->addGlobalParams( $oShop );
01926 }
01927
01928 return $this->_aShops[$iLangId];
01929 }
01930
01939 protected function _setSmtpAuthInfo( $sUserName = null, $sUserPassword = null )
01940 {
01941 $this->set( "SMTPAuth", true );
01942 $this->set( "Username", $sUserName );
01943 $this->set( "Password", $sUserPassword );
01944 }
01945
01953 protected function _setSmtpDebug( $blDebug = null )
01954 {
01955 $this->set( "SMTPDebug", $blDebug );
01956 }
01957
01963 protected function _setMailerPluginDir()
01964 {
01965 $this->set( "PluginDir", getShopBasePath() . "core/phpmailer/" );
01966 }
01967
01974 protected function _makeOutputProcessing()
01975 {
01976 $oOutput = oxNew( "oxoutput" );
01977 $this->setBody( $oOutput->process($this->getBody(), "oxemail") );
01978 $this->setAltBody( $oOutput->process($this->getAltBody(), "oxemail") );
01979 $oOutput->processEmail( $this );
01980 }
01981
01987 protected function _sendMail()
01988 {
01989 $blResult = false;
01990 try {
01991 $blResult = parent::send();
01992 } catch( Exception $oEx ) {
01993 }
01994
01995 return $blResult;
01996 }
01997 }