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