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
00336 $this->_sendMailErrorMsg();
00337
00338
00339 $this->setMailer( 'mail' );
00340 $blRet = $this->_sendMail();
00341 }
00342 } else {
00343
00344 $this->setMailer( 'mail' );
00345 $blRet = $this->_sendMail();
00346 }
00347
00348 if ( !$blRet ) {
00349
00350 $this->_sendMailErrorMsg();
00351 }
00352
00353 return $blRet;
00354 }
00355
00364 protected function _setSmtpProtocol($sUrl)
00365 {
00366 $sProtocol = '';
00367 $sSmtpHost = $sUrl;
00368 $aMatch = array();
00369 if ( getStr()->preg_match('@^([0-9a-z]+://)?(.*)$@i', $sUrl, $aMatch ) ) {
00370 if ($aMatch[1]) {
00371 if (($aMatch[1] == 'ssl://') || ($aMatch[1] == 'tls://')) {
00372 $this->set( "SMTPSecure", substr($aMatch[1], 0, 3) );
00373 } else {
00374 $sProtocol = $aMatch[1];
00375 }
00376 }
00377 $sSmtpHost = $aMatch[2];
00378 }
00379
00380 return $sProtocol.$sSmtpHost;
00381 }
00382
00390 public function setSmtp( $oShop = null )
00391 {
00392 $myConfig = $this->getConfig();
00393 $oShop = ( $oShop ) ? $oShop : $this->_getShop();
00394
00395 $sSmtpUrl = $this->_setSmtpProtocol($oShop->oxshops__oxsmtp->value);
00396
00397 if ( !$this->_isValidSmtpHost( $sSmtpUrl ) ) {
00398 $this->setMailer( "mail" );
00399 return;
00400 }
00401
00402 $this->setHost( $sSmtpUrl );
00403 $this->setMailer( "smtp" );
00404
00405 if ( $oShop->oxshops__oxsmtpuser->value ) {
00406 $this->_setSmtpAuthInfo( $oShop->oxshops__oxsmtpuser->value, $oShop->oxshops__oxsmtppwd->value );
00407 }
00408
00409 if ( $myConfig->getConfigParam( 'iDebug' ) == 6 ) {
00410 $this->_setSmtpDebug( true );
00411 }
00412 }
00413
00421 protected function _isValidSmtpHost( $sSmtpHost )
00422 {
00423 $blIsSmtp = false;
00424 if ( $sSmtpHost ) {
00425 $sSmtpPort = $this->SMTP_PORT;
00426 $aMatch = array();
00427 if ( getStr()->preg_match('@^(.*?)(:([0-9]+))?$@i', $sSmtpHost, $aMatch)) {
00428 $sSmtpHost = $aMatch[1];
00429 $sSmtpPort = (int)$aMatch[3];
00430 if (!$sSmtpPort) {
00431 $sSmtpPort = $this->SMTP_PORT;
00432 }
00433 }
00434 if ( $blIsSmtp = (bool) ( $rHandle = @fsockopen( $sSmtpHost, $sSmtpPort, $iErrNo, $sErrStr, 30 )) ) {
00435
00436 fclose( $rHandle );
00437 }
00438 }
00439
00440 return $blIsSmtp;
00441 }
00442
00452 public function sendOrderEmailToUser( $oOrder, $sSubject = null )
00453 {
00454 $myConfig = $this->getConfig();
00455
00456
00457 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00458
00459
00460 $oShop = $this->_getShop();
00461 $this->_setMailParams( $oShop );
00462
00463
00464
00465 $oOrder->oDelSet = $oOrder->getDelSet();
00466
00467 $oUser = $oOrder->getOrderUser();
00468
00469 $oSmarty = $this->_getSmarty();
00470 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00471 $oSmarty->assign( "order", $oOrder);
00472 $oSmarty->assign( "shop", $oShop );
00473 $oSmarty->assign( "oViewConf", $oShop );
00474 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00475 $oSmarty->assign( "user", $oUser );
00476 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00477 $oSmarty->assign( "basket", $oOrder->getBasket() );
00478 $oSmarty->assign( "payment", $oOrder->getPayment() );
00479 if ( $oUser ) {
00480 $oSmarty->assign( "reviewuserhash", $oUser->getReviewUserHash( $oUser->getId() ) );
00481 }
00482 $oSmarty->assign( "paymentinfo", $myConfig->getActiveShop() );
00483
00484
00485 $oSmarty->assign( "iswishlist", true );
00486 $oSmarty->assign( "isreview", true );
00487
00488 if ( $aVoucherList = $oOrder->getVoucherList() ) {
00489 $oSmarty->assign( "vouchers", $aVoucherList );
00490 }
00491
00492 $oOutputProcessor = oxNew( "oxoutput" );
00493 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00494
00495 foreach ( $aNewSmartyArray as $key => $val ) {
00496 $oSmarty->assign( $key, $val );
00497 }
00498
00499 $this->setBody( $oSmarty->fetch( $this->_sOrderUserTemplate ) );
00500 $this->setAltBody( $oSmarty->fetch( $this->_sOrderUserPlainTemplate ) );
00501
00502
00503 if ( $sSubject === null ) {
00504 if ( $oSmarty->template_exists( $this->_sOrderUserSubjectTemplate) ) {
00505 $sSubject = $oSmarty->fetch( $this->_sOrderUserSubjectTemplate );
00506 } else {
00507 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00508 }
00509 }
00510
00511 $this->setSubject( $sSubject );
00512
00513 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00514
00515 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00516 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00517
00518 $blSuccess = $this->send();
00519
00520 return $blSuccess;
00521 }
00522
00532 public function sendOrderEmailToOwner( $oOrder, $sSubject = null )
00533 {
00534 $myConfig = $this->getConfig();
00535
00536 $oShop = $this->_getShop();
00537
00538
00539 $this->_clearMailer();
00540
00541
00542 $oOrder = $this->_addUserInfoOrderEMail( $oOrder );
00543
00544
00545 $sFullName = $oOrder->getOrderUser()->oxuser__oxfname->getRawValue() . " " . $oOrder->getOrderUser()->oxuser__oxlname->getRawValue();
00546 $this->setFrom( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00547
00548 $oLang = oxLang::getInstance();
00549 $iOrderLang = $oLang->getObjectTplLanguage();
00550
00551
00552
00553 if ( $oShop->getLanguage() != $iOrderLang ) {
00554 $oShop = $this->_getShop( $iOrderLang );
00555 }
00556
00557 $this->setSmtp( $oShop );
00558
00559
00560 $oSmarty = $this->_getSmarty();
00561 $oSmarty->assign( "charset", $oLang->translateString("charset"));
00562 $oSmarty->assign( "order", $oOrder );
00563 $oSmarty->assign( "shop", $oShop );
00564 $oSmarty->assign( "oViewConf", $oShop );
00565 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00566 $oSmarty->assign( "user", $oOrder->getOrderUser() );
00567 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
00568 $oSmarty->assign( "basket", $oOrder->getBasket() );
00569 $oSmarty->assign( "payment", $oOrder->getPayment() );
00570
00571
00572 $oSmarty->assign( "iswishlist", true);
00573
00574 if( $oOrder->getVoucherList() )
00575 $oSmarty->assign( "vouchers", $oOrder->getVoucherList() );
00576
00577 $oOutputProcessor = oxNew( "oxoutput" );
00578 $aNewSmartyArray = $oOutputProcessor->processViewArray($oSmarty->get_template_vars(), "oxemail");
00579 foreach ($aNewSmartyArray as $key => $val)
00580 $oSmarty->assign( $key, $val );
00581
00582 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerTemplate, false ) ) );
00583 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sOrderOwnerPlainTemplate, false ) ) );
00584
00585
00586
00587 if ( $sSubject === null ) {
00588 if ( $oSmarty->template_exists( $this->_sOrderOwnerSubjectTemplate) ) {
00589 $sSubject = $oSmarty->fetch( $this->_sOrderOwnerSubjectTemplate );
00590 } else {
00591 $sSubject = $oShop->oxshops__oxordersubject->getRawValue()." (#".$oOrder->oxorder__oxordernr->value.")";
00592 }
00593 }
00594
00595 $this->setSubject( $sSubject );
00596 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oLang->translateString("order") );
00597
00598 if ( $oOrder->getOrderUser()->oxuser__oxusername->value != "admin" )
00599 $this->setReplyTo( $oOrder->getOrderUser()->oxuser__oxusername->value, $sFullName );
00600
00601 $blSuccess = $this->send();
00602
00603
00604 $oRemark = oxNew( "oxremark" );
00605 $oRemark->oxremark__oxtext = new oxField($this->getAltBody(), oxField::T_RAW);
00606 $oRemark->oxremark__oxparentid = new oxField($oOrder->getOrderUser()->getId(), oxField::T_RAW);
00607 $oRemark->oxremark__oxtype = new oxField("o", oxField::T_RAW);
00608 $oRemark->save();
00609
00610
00611 if ( $myConfig->getConfigParam( 'iDebug' ) == 6) {
00612 oxUtils::getInstance()->showMessageAndExit( "" );
00613 }
00614
00615 return $blSuccess;
00616 }
00617
00627 public function sendRegisterConfirmEmail( $oUser, $sSubject = null )
00628 {
00629
00630 $oSmarty = $this->_getSmarty();
00631 $oSmarty->assign( "contentident", "oxregisteraltemail" );
00632 $oSmarty->assign( "contentplainident", "oxregisterplainaltemail" );
00633
00634
00635 return $this->sendRegisterEmail( $oUser, $sSubject );
00636 }
00637
00647 public function sendRegisterEmail( $oUser, $sSubject = null )
00648 {
00649
00650 $oUser = $this->_addUserRegisterEmail( $oUser );
00651
00652
00653 $oShop = $this->_getShop();
00654
00655
00656 $this->_setMailParams( $oShop );
00657
00658
00659 $oSmarty = $this->_getSmarty();
00660 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00661 $oSmarty->assign( "shop", $oShop );
00662 $oSmarty->assign( "oViewConf", $oShop );
00663 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00664 $oSmarty->assign( "user", $oUser );
00665
00666 $oOutputProcessor = oxNew( "oxoutput" );
00667 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00668
00669 foreach ( $aNewSmartyArray as $key => $val ) {
00670 $oSmarty->assign( $key, $val );
00671 }
00672
00673 $this->setBody( $oSmarty->fetch( $this->_sRegisterTemplate ) );
00674 $this->setAltBody( $oSmarty->fetch( $this->_sRegisterTemplatePlain ) );
00675
00676 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxregistersubject->getRawValue() );
00677
00678 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00679
00680 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00681 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00682
00683 return $this->send();
00684 }
00685
00695 public function sendForgotPwdEmail( $sEmailAddress, $sSubject = null )
00696 {
00697 $myConfig = $this->getConfig();
00698 $oDb = oxDb::getDb();
00699
00700
00701 $oShop = $this->_getShop();
00702
00703
00704 $oShop = $this->_addForgotPwdEmail( $oShop);
00705
00706
00707 $this->_setMailParams( $oShop );
00708
00709
00710 $sWhere = "oxuser.oxactive = 1 and oxuser.oxusername = ".$oDb->quote( $sEmailAddress )." and oxuser.oxpassword != ''";
00711 $sOrder = "";
00712 if ( $myConfig->getConfigParam( 'blMallUsers' )) {
00713 $sOrder = "order by oxshopid = '".$oShop->getId()."' desc";
00714 } else {
00715 $sWhere .= " and oxshopid = '".$oShop->getId()."'";
00716 }
00717
00718 $sSelect = "select oxid from oxuser where $sWhere $sOrder";
00719 if ( ( $sOxId = $oDb->getOne( $sSelect ) ) ) {
00720
00721 $oUser = oxNew( 'oxuser' );
00722 if ( $oUser->load($sOxId) ) {
00723
00724 $oSmarty = $this->_getSmarty();
00725 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset"));
00726 $oSmarty->assign( "shop", $oShop );
00727 $oSmarty->assign( "oViewConf", $oShop );
00728 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00729 $oSmarty->assign( "user", $oUser );
00730
00731 $oOutputProcessor = oxNew( "oxoutput" );
00732 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00733
00734 foreach ( $aNewSmartyArray as $key => $val ) {
00735 $oSmarty->assign($key, $val);
00736 }
00737
00738 $this->setBody( $oSmarty->fetch( $this->_sForgotPwdTemplate ) );
00739 $this->setAltBody( $oSmarty->fetch( $this->_sForgotPwdTemplatePlain ) );
00740
00741
00742 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxforgotpwdsubject->getRawValue() );
00743
00744 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00745
00746 $this->setRecipient( $sEmailAddress, $sFullName );
00747 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00748
00749 return $this->send();
00750 }
00751 }
00752
00753 return false;
00754 }
00755
00766 public function sendContactMail( $sEmailAddress = null, $sSubject = null, $sMessage = null )
00767 {
00768
00769
00770 $oShop = $this->_getShop();
00771
00772
00773 $this->_setMailParams( $oShop );
00774
00775 $this->setBody( $sMessage );
00776 $this->setSubject( $sSubject );
00777
00778 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
00779 $this->setFrom( $sEmailAddress, "" );
00780 $this->setReplyTo( $sEmailAddress, "" );
00781
00782 return $this->send();
00783 }
00784
00794 public function sendNewsletterDbOptInMail( $oUser, $sSubject = null )
00795 {
00796 $oLang = oxLang::getInstance();
00797
00798
00799 $oUser = $this->_addNewsletterDbOptInMail( $oUser );
00800
00801
00802 $oShop = $this->_getShop();
00803
00804
00805 $this->_setMailParams( $oShop );
00806
00807
00808 $oSmarty = $this->_getSmarty();
00809 $oSmarty->assign( "charset", $oLang->translateString("charset"));
00810 $oSmarty->assign( "shop", $oShop );
00811 $oSmarty->assign( "oViewConf", $oShop );
00812 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
00813 $oSmarty->assign( "subscribeLink", $this->_getNewsSubsLink($oUser->oxuser__oxid->value) );
00814 $oSmarty->assign( "user", $oUser );
00815
00816 $oOutputProcessor = oxNew( "oxoutput" );
00817 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00818 foreach ( $aNewSmartyArray as $key => $val ) {
00819 $oSmarty->assign( $key, $val );
00820 }
00821
00822 $this->setBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplate ) );
00823 $this->setAltBody( $oSmarty->fetch( $this->_sNewsletterOptInTemplatePlain ) );
00824 $this->setSubject( ( $sSubject !== null ) ? $sSubject : oxLang::getInstance()->translateString("EMAIL_NEWSLETTERDBOPTINMAIL_SUBJECT") . " " . $oShop->oxshops__oxname->getRawValue() );
00825
00826 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00827
00828 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00829 $this->setFrom( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00830 $this->setReplyTo( $oShop->oxshops__oxinfoemail->value, $oShop->oxshops__oxname->getRawValue() );
00831
00832 return $this->send();
00833 }
00834
00842 protected function _getNewsSubsLink( $sId )
00843 {
00844 $myConfig = $this->getConfig();
00845 $iActShopLang = $myConfig->getActiveShop()->getLanguage();
00846
00847 $sUrl = $myConfig->getShopHomeURL().'cl=newsletter&fnc=addme&uid='.$sId;
00848 $sUrl.= ( $iActShopLang ) ? '&lang='.$iActShopLang : "";
00849 return $sUrl;
00850 }
00851
00862 public function sendNewsletterMail( $oNewsLetter, $oUser, $sSubject = null )
00863 {
00864
00865 $oShop = $this->_getShop();
00866
00867
00868 $this->_setMailParams( $oShop );
00869
00870 $sBody = $oNewsLetter->getHtmlText();
00871
00872 if ( !empty($sBody) ) {
00873 $this->setBody( $sBody );
00874 $this->setAltBody( $oNewsLetter->getPlainText() );
00875 } else {
00876 $this->isHtml( false );
00877 $this->setBody( $oNewsLetter->getPlainText() );
00878 }
00879
00880 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oNewsLetter->oxnewsletter__oxtitle->getRawValue() );
00881
00882 $sFullName = $oUser->oxuser__oxfname->getRawValue() . " " . $oUser->oxuser__oxlname->getRawValue();
00883 $this->setRecipient( $oUser->oxuser__oxusername->value, $sFullName );
00884 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
00885
00886 return $this->send();
00887 }
00888
00898 public function sendSuggestMail( $oParams, $oProduct )
00899 {
00900 $myConfig = $this->getConfig();
00901
00902
00903 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00904
00905
00906 $oShop = $this->_getShop( $iCurrLang );
00907
00908
00909 if ( $oProduct->getLanguage() != $iCurrLang ) {
00910 $oProduct->setLanguage( $iCurrLang );
00911 $oProduct->load( $oProduct->getId() );
00912 }
00913
00914
00915 $this->setFrom( $oParams->send_email, $oParams->send_name );
00916 $this->setSMTP();
00917
00918
00919 $oSmarty = $this->_getSmarty();
00920 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00921 $oSmarty->assign( "shop", $oShop );
00922 $oSmarty->assign( "oViewConf", $oShop );
00923 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00924 $oSmarty->assign( "userinfo", $oParams );
00925 $oSmarty->assign( "product", $oProduct );
00926
00927 $sArticleUrl = $oProduct->getLink();
00928
00929
00930 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00931 $sArticleUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sArticleUrl );
00932 $sArticleUrl .= "su=" . $oActiveUser->getId();
00933 }
00934
00935 $oSmarty->assign( "sArticleUrl", $sArticleUrl );
00936
00937 $oOutputProcessor = oxNew( "oxoutput" );
00938 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00939
00940 foreach ( $aNewSmartyArray as $key => $val ) {
00941 $oSmarty->assign( $key, $val );
00942 }
00943
00944 $this->setBody( $oSmarty->fetch( $this->_sSuggestTemplate ) );
00945 $this->setAltBody( $oSmarty->fetch( $this->_sSuggestTemplatePlain ) );
00946 $this->setSubject( $oParams->send_subject );
00947
00948 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
00949 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
00950
00951 return $this->send();
00952 }
00953
00962 public function sendInviteMail( $oParams )
00963 {
00964 $myConfig = $this->getConfig();
00965
00966
00967 $iCurrLang = $myConfig->getActiveShop()->getLanguage();
00968
00969
00970 $oShop = $this->_getShop( $iCurrLang );
00971
00972
00973 $this->setFrom( $oParams->send_email, $oParams->send_name );
00974 $this->setSMTP();
00975
00976
00977 $oSmarty = oxUtilsView::getInstance()->getSmarty();
00978 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
00979 $oSmarty->assign( "shop", $oShop );
00980 $oSmarty->assign( "oViewConf", $oShop );
00981 $oSmarty->assign( "oView", $myConfig->getActiveView() );
00982 $oSmarty->assign( "userinfo", $oParams );
00983 $oSmarty->assign( "sShopUrl", $myConfig->getShopCurrentUrl() );
00984
00985 $sHomeUrl = $oShop->getHomeLink();
00986
00987
00988 if ( $myConfig->getActiveView()->isActive('Invitations') && $oActiveUser = $oShop->getUser() ) {
00989 $sHomeUrl = oxUtilsUrl::getInstance()->appendParamSeparator( $sHomeUrl );
00990 $sHomeUrl .= "su=" . $oActiveUser->getId();
00991 }
00992
00993 $oSmarty->assign( "sHomeUrl", $sHomeUrl );
00994
00995 $oOutputProcessor = oxNew( "oxoutput" );
00996 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
00997
00998 foreach ( $aNewSmartyArray as $key => $val ) {
00999 $oSmarty->assign( $key, $val );
01000 }
01001
01002 $this->setBody( $oSmarty->fetch( $this->_sInviteTemplate ) );
01003
01004 $this->setAltBody( $oSmarty->fetch( $this->_sInviteTemplatePlain ) );
01005 $this->setSubject( $oParams->send_subject );
01006
01007 if ( is_array($oParams->rec_email) && count($oParams->rec_email) > 0 ) {
01008 foreach ( $oParams->rec_email as $sEmail ) {
01009 if ( !empty( $sEmail ) ) {
01010 $this->setRecipient( $sEmail );
01011 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01012 $this->send();
01013 $this->clearAllRecipients();
01014 }
01015 }
01016
01017 return true;
01018 }
01019
01020 return false;
01021 }
01022
01032 public function sendSendedNowMail( $oOrder, $sSubject = null )
01033 {
01034 $myConfig = $this->getConfig();
01035
01036 $iOrderLang = (int) ( isset( $oOrder->oxorder__oxlang->value ) ? $oOrder->oxorder__oxlang->value : 0 );
01037
01038
01039 $oShop = $this->_getShop( $iOrderLang );
01040
01041
01042 $this->_setMailParams( $oShop );
01043
01044
01045
01046
01047
01048 $oLang = oxLang::getInstance();
01049 $oSmarty = $this->_getSmarty();
01050 $oSmarty->assign( "charset", $oLang->translateString("charset"));
01051 $oSmarty->assign( "shop", $oShop );
01052 $oSmarty->assign( "oViewConf", $oShop );
01053 $oSmarty->assign( "oView", $myConfig->getActiveView() );
01054 $oSmarty->assign( "order", $oOrder );
01055 $oSmarty->assign( "currency", $myConfig->getActShopCurrencyObject() );
01056
01057
01058 $oSmarty->assign( "isreview", true);
01059 $oUser = oxNew( 'oxuser' );
01060 $oSmarty->assign( "reviewuserhash", $oUser->getReviewUserHash($oOrder->oxorder__oxuserid->value) );
01061
01062 $oOutputProcessor = oxNew( "oxoutput" );
01063 $aNewSmartyArray = $oOutputProcessor->processViewArray( $oSmarty->get_template_vars(), "oxemail" );
01064
01065 foreach ( $aNewSmartyArray as $key => $val ) {
01066 $oSmarty->assign( $key, $val );
01067 }
01068
01069
01070 $aStore['INCLUDE_ANY'] = $oSmarty->security_settings['INCLUDE_ANY'];
01071
01072 $iOldTplLang = $oLang->getTplLanguage();
01073 $iOldBaseLang = $oLang->getTplLanguage();
01074 $oLang->setTplLanguage( $iOrderLang );
01075 $oLang->setBaseLanguage( $iOrderLang );
01076
01077 $oSmarty->security_settings['INCLUDE_ANY'] = true;
01078
01079 $this->setBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplate, false ) ) );
01080 $this->setAltBody( $oSmarty->fetch( $myConfig->getTemplatePath( $this->_sSenedNowTemplatePlain, false ) ) );
01081 $oLang->setTplLanguage( $iOldTplLang );
01082 $oLang->setBaseLanguage( $iOldBaseLang );
01083
01084 $oSmarty->security_settings['INCLUDE_ANY'] = $aStore['INCLUDE_ANY'] ;
01085
01086
01087 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oShop->oxshops__oxsendednowsubject->getRawValue() );
01088
01089 $sFullName = $oOrder->oxorder__oxbillfname->getRawValue() . " " . $oOrder->oxorder__oxbilllname->getRawValue();
01090
01091 $this->setRecipient( $oOrder->oxorder__oxbillemail->value, $sFullName );
01092 $this->setReplyTo( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01093 return $this->send();
01094 }
01095
01110 public function sendBackupMail( $aAttFiles, $sAttPath, $sEmailAddress, $sSubject, $sMessage, &$aStatus, &$aError )
01111 {
01112
01113
01114
01115
01116
01117
01118
01119 $oShop = $this->_getShop();
01120
01121
01122 $this->_setMailParams( $oShop );
01123
01124 $this->setBody( $sMessage );
01125 $this->setSubject( $sSubject );
01126
01127 $this->setRecipient( $oShop->oxshops__oxinfoemail->value, "" );
01128 $sEmailAddress = $sEmailAddress ? $sEmailAddress : $oShop->oxshops__oxowneremail->value;
01129
01130 $this->setFrom( $sEmailAddress, "" );
01131 $this->setReplyTo( $sEmailAddress, "" );
01132
01133
01134 $blAttashSucc = true;
01135 $sAttPath = oxUtilsFile::getInstance()->normalizeDir($sAttPath);
01136 foreach ( $aAttFiles as $iNum => $sAttFile ) {
01137 if ( file_exists($sAttPath . $sAttFile) && is_file($sAttPath . $sAttFile) ) {
01138 $blAttashSucc = $this->addAttachment( $sAttPath, $sAttFile );
01139 } else {
01140 $blAttashSucc = false;
01141 $aError[] = array( 5, $sAttFile );
01142 }
01143 }
01144
01145 if ( !$blAttashSucc ) {
01146 $aError[] = array( 4, "" );
01147 $this->clearAttachments();
01148 return false;
01149 }
01150
01151 $aStatus[] = 3;
01152 $blSend = $this->send();
01153 $this->clearAttachments();
01154
01155 return $blSend;
01156 }
01157
01168 public function sendEmail( $sTo, $sSubject, $sBody )
01169 {
01170
01171 $this->_setMailParams();
01172
01173 if ( is_array($sTo) ) {
01174 foreach ($sTo as $sAddress) {
01175 $this->setRecipient( $sAddress, "" );
01176 $this->setReplyTo( $sAddress, "" );
01177 }
01178 } else {
01179 $this->setRecipient( $sTo, "" );
01180 $this->setReplyTo( $sTo, "" );
01181 }
01182
01183
01184 $this->isHtml( false );
01185
01186 $this->setSubject( $sSubject );
01187 $this->setBody( $sBody );
01188
01189 return $this->send();
01190 }
01191
01200 public function sendStockReminder( $aBasketContents, $sSubject = null )
01201 {
01202 $blSend = false;
01203
01204 $oArticleList = oxNew( "oxarticlelist" );
01205 $oArticleList->loadStockRemindProducts( $aBasketContents );
01206
01207
01208 if ( $oArticleList->count() ) {
01209 $oShop = $this->_getShop();
01210
01211
01212 $this->_setMailParams( $oShop );
01213 $oLang = oxLang::getInstance();
01214
01215 $oSmarty = $this->_getSmarty();
01216 $oSmarty->assign( "charset", $oLang->translateString( "charset" ) );
01217 $oSmarty->assign( "shop", $oShop );
01218 $oSmarty->assign( "oViewConf", $oShop );
01219 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01220 $oSmarty->assign( "articles", $oArticleList );
01221
01222 $this->setRecipient( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01223 $this->setFrom( $oShop->oxshops__oxowneremail->value, $oShop->oxshops__oxname->getRawValue() );
01224 $this->setBody( $oSmarty->fetch( $this->getConfig()->getTemplatePath( $this->_sReminderMailTemplate, false ) ) );
01225 $this->setAltBody( "" );
01226 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_STOCKREMINDER_SUBJECT' ) );
01227
01228 $blSend = $this->send();
01229 }
01230
01231 return $blSend;
01232 }
01233
01242 public function sendWishlistMail( $oParams )
01243 {
01244 $myConfig = $this->getConfig();
01245
01246 $this->_clearMailer();
01247
01248
01249 $oShop = $this->_getShop();
01250
01251
01252 $this->setFrom( $oParams->send_email, $oParams->send_name );
01253 $this->setSMTP();
01254
01255
01256 $oSmarty = $this->_getSmarty();
01257 $oSmarty->assign( "charset", oxLang::getInstance()->translateString("charset") );
01258 $oSmarty->assign( "shop", $oShop );
01259 $oSmarty->assign( "oViewConf", $oShop );
01260 $oSmarty->assign( "oView", $myConfig->getActiveView() );
01261 $oSmarty->assign( "userinfo", $oParams );
01262
01263 $this->setBody( $oSmarty->fetch( $this->_sWishListTemplate ) );
01264 $this->setAltBody( $oSmarty->fetch( $this->_sWishListTemplatePlain ) );
01265 $this->setSubject( $oParams->send_subject );
01266
01267 $this->setRecipient( $oParams->rec_email, $oParams->rec_name );
01268 $this->setReplyTo( $oParams->send_email, $oParams->send_name );
01269
01270 return $this->send();
01271 }
01272
01283 public function sendPriceAlarmNotification( $aParams, $oAlarm, $sSubject = null )
01284 {
01285 $this->_clearMailer();
01286 $oShop = $this->_getShop();
01287
01288
01289 $this->_setMailParams( $oShop );
01290
01291 $iAlarmLang = $oAlarm->oxpricealarm__oxlang->value;
01292
01293 $oArticle = oxNew( "oxarticle" );
01294 $oArticle->setSkipAbPrice( true );
01295 $oArticle->loadInLang( $iAlarmLang, $aParams['aid'] );
01296
01297 $oCur = $this->getConfig()->getActShopCurrencyObject();
01298 $oLang = oxLang::getInstance();
01299
01300
01301 $oSmarty = $this->_getSmarty();
01302 $oSmarty->assign( "shop", $oShop );
01303 $oSmarty->assign( "oViewConf", $oShop );
01304 $oSmarty->assign( "oView", $this->getConfig()->getActiveView() );
01305 $oSmarty->assign( "product", $oArticle );
01306 $oSmarty->assign( "email", $aParams['email']);
01307 $oSmarty->assign( "bidprice", $oLang->formatCurrency( $oAlarm->oxpricealarm__oxprice->value, $oCur ) );
01308 $oSmarty->assign( "currency", $oCur );
01309
01310 $this->setRecipient( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01311 $this->setSubject( ( $sSubject !== null ) ? $sSubject : $oLang->translateString( 'EMAIL_PRICEALARM_OWNER_SUBJECT', $iAlarmLang ) . " " . $oArticle->oxarticles__oxtitle->getRawValue() );
01312 $this->setBody( $oSmarty->fetch( $this->_sOwnerPricealarmTemplate ) );
01313 $this->setFrom( $aParams['email'], "" );
01314 $this->setReplyTo( $aParams['email'], "" );
01315
01316 return $this->send();
01317 }
01318
01330 protected function _includeImages($sImageDir = null, $sImageDirNoSSL = null, $sDynImageDir = null, $sAbsImageDir = null, $sAbsDynImageDir = null)
01331 {
01332 $sBody = $this->getBody();
01333 if (preg_match_all('/<\s*img\s+[^>]*?src[\s]*=[\s]*[\'"]?([^[\'">]]+|.*?)?[\'">]/i', $sBody, $matches, PREG_SET_ORDER)) {
01334
01335 $oFileUtils = oxUtilsFile::getInstance();
01336 $blReSetBody = false;
01337
01338
01339 $sDynImageDir = $oFileUtils->normalizeDir( $sDynImageDir );
01340 $sImageDir = $oFileUtils->normalizeDir( $sImageDir );
01341 $sImageDirNoSSL = $oFileUtils->normalizeDir( $sImageDirNoSSL );
01342
01343 if (is_array($matches) && count($matches)) {
01344 $aImageCache = array();
01345 $myUtils = oxUtils::getInstance();
01346 $myUtilsObject = oxUtilsObject::getInstance();
01347
01348 foreach ($matches as $aImage) {
01349
01350 $image = $aImage[1];
01351 $sFileName = '';
01352 if ( strpos( $image, $sDynImageDir ) === 0 ) {
01353 $sFileName = $oFileUtils->normalizeDir( $sAbsDynImageDir ) . str_replace( $sDynImageDir, '', $image );
01354 } elseif ( strpos( $image, $sImageDir ) === 0 ) {
01355 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDir, '', $image );
01356 } elseif ( strpos( $image, $sImageDirNoSSL ) === 0 ) {
01357 $sFileName = $oFileUtils->normalizeDir( $sAbsImageDir ) . str_replace( $sImageDirNoSSL, '', $image );
01358 }
01359
01360 if ($sFileName && @is_file($sFileName)) {
01361 $sCId = '';
01362 if ( isset( $aImageCache[$sFileName] ) && $aImageCache[$sFileName] ) {
01363 $sCId = $aImageCache[$sFileName];
01364 } else {
01365 $sCId = $myUtilsObject->generateUID();
01366 $sMIME = $myUtils->oxMimeContentType($sFileName);
01367 if ($sMIME == 'image/jpeg' || $sMIME == 'image/gif' || $sMIME == 'image/png') {
01368 if ( $this->addEmbeddedImage( $sFileName, $sCId, "image", "base64", $sMIME ) ) {
01369 $aImageCache[$sFileName] = $sCId;
01370 } else {
01371 $sCId = '';
01372 }
01373 }
01374 }
01375 if ( $sCId && $sCId == $aImageCache[$sFileName] ) {
01376 if ( $sReplTag = str_replace( $image, 'cid:'.$sCId, $aImage[0] ) ) {
01377 $sBody = str_replace($aImage[0], $sReplTag, $sBody );
01378 $blReSetBody = true;
01379 }
01380 }
01381 }
01382 }
01383 }
01384
01385 if ( $blReSetBody ) {
01386 $this->setBody( $sBody );
01387 }
01388 }
01389 }
01390
01398 public function setSubject( $sSubject = null )
01399 {
01400
01401 $sSubject = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sSubject);
01402
01403 $this->set( "Subject", $sSubject );
01404 }
01405
01411 public function getSubject()
01412 {
01413 return $this->Subject;
01414 }
01415
01425 public function setBody( $sBody = null, $blClearSid = true )
01426 {
01427 if ( $blClearSid ) {
01428 $sBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sBody);
01429 }
01430
01431 $this->set( "Body", $sBody );
01432 }
01433
01439 public function getBody()
01440 {
01441 return $this->Body;
01442 }
01443
01453 public function setAltBody( $sAltBody = null, $blClearSid = true )
01454 {
01455 if ( $blClearSid ) {
01456 $sAltBody = getStr()->preg_replace('/((\?|&(amp;)?)(force_)?(admin_)?)sid=[A-Z0-9\.]+/i', '\1sid=x&shp=' . $this->getConfig()->getShopId(), $sAltBody);
01457 }
01458
01459
01460 $sAltBody = str_replace(array('&', '"', ''', '<', '>'), array('&', '"', "'", '<', '>' ), $sAltBody);
01461
01462 $this->set( "AltBody", $sAltBody );
01463 }
01464
01470 public function getAltBody()
01471 {
01472 return $this->AltBody;
01473 }
01474
01483 public function setRecipient( $sAddress = null, $sName = null )
01484 {
01485 try {
01486 parent::AddAddress( $sAddress, $sName );
01487
01488
01489 $this->_aRecipients[] = array( $sAddress, $sName );
01490 } catch( Exception $oEx ) {
01491 }
01492 }
01493
01501 public function getRecipient()
01502 {
01503 return $this->_aRecipients;
01504 }
01505
01512 public function clearAllRecipients()
01513 {
01514 $this->_aRecipients = array();
01515 parent::clearAllRecipients();
01516 }
01517
01529 public function setReplyTo( $sEmail = null, $sName = null )
01530 {
01531 if ( !oxUtils::getInstance()->isValidEmail( $sEmail ) ) {
01532 $sEmail = $this->_getShop()->oxshops__oxorderemail->value;
01533 }
01534
01535 $this->_aReplies[] = array( $sEmail, $sName );
01536
01537 try {
01538 parent::addReplyTo( $sEmail, $sName );
01539 } catch( Exception $oEx ) {
01540 }
01541 }
01542
01548 public function getReplyTo()
01549 {
01550 return $this->_aReplies;
01551 }
01552
01558 public function clearReplyTos()
01559 {
01560 $this->_aReplies = array();
01561 parent::clearReplyTos();
01562 }
01563
01572 public function setFrom( $sFromAdress, $sFromName = null )
01573 {
01574
01575
01576
01577 $sFromAdress = substr($sFromAdress, 0, 150);
01578 $sFromName = substr($sFromName, 0, 150);
01579
01580 try {
01581 parent::setFrom( $sFromAdress, $sFromName );
01582 } catch( Exception $oEx ) {
01583 }
01584 }
01585
01591 public function getFrom()
01592 {
01593 return $this->From;
01594 }
01595
01601 public function getFromName()
01602 {
01603 return $this->FromName;
01604 }
01605
01614 public function setCharSet( $sCharSet = null )
01615 {
01616 $this->set( "CharSet", $sCharSet ? $sCharSet : oxLang::getInstance()->translateString( "charset" ) );
01617 }
01618
01624 public function getCharSet()
01625 {
01626 return $this->CharSet;
01627 }
01628
01636 public function setMailer( $sMailer = null )
01637 {
01638 $this->set( "Mailer", $sMailer );
01639 }
01640
01646 public function getMailer()
01647 {
01648 return $this->Mailer;
01649 }
01650
01658 public function setHost( $sHost = null )
01659 {
01660 $this->set( "Host", $sHost );
01661 }
01662
01668 public function getErrorInfo()
01669 {
01670 return $this->ErrorInfo;
01671 }
01672
01681 public function setMailWordWrap( $iWordWrap = null )
01682 {
01683 $this->set( "WordWrap", $iWordWrap );
01684 }
01685
01693 public function setUseInlineImages( $blUseImages = null )
01694 {
01695 $this->_blInlineImgEmail = $blUseImages;
01696 }
01697
01708 public function addAttachment( $sAttPath, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01709 {
01710 $sFullPath = $sAttPath . $sAttFile;
01711
01712 $this->_aAttachments[] = array( $sFullPath, $sAttFile, $sEncoding, $sType );
01713 $blResult = false;
01714
01715 try {
01716 $blResult = parent::addAttachment( $sFullPath, $sAttFile, $sEncoding, $sType );
01717 } catch( Exception $oEx ) {
01718 }
01719
01720 return $blResult;
01721 }
01722
01734 public function addEmbeddedImage( $sFullPath, $sCid, $sAttFile = '', $sEncoding = 'base64', $sType = 'application/octet-stream' )
01735 {
01736 $this->_aAttachments[] = array( $sFullPath, basename($sFullPath), $sAttFile, $sEncoding, $sType, false, 'inline', $sCid );
01737 return parent::addEmbeddedImage( $sFullPath, $sCid, $sAttFile, $sEncoding, $sType );
01738 }
01739
01745 public function getAttachments()
01746 {
01747 return $this->_aAttachments;
01748 }
01749
01755 public function clearAttachments()
01756 {
01757 $this->_aAttachments = array();
01758 return parent::clearAttachments();
01759 }
01760
01770 public function headerLine($sName, $sValue)
01771 {
01772 if (stripos($sName, 'X-') !== false) {
01773 return;
01774 }
01775 return parent::headerLine($sName, $sValue);
01776 }
01777
01783 protected function _getUseInlineImages()
01784 {
01785 return $this->_blInlineImgEmail;
01786 }
01787
01793 protected function _sendMailErrorMsg()
01794 {
01795
01796 $sToAdress = "";
01797 $sToName = "";
01798
01799 $aRecipients = $this->getRecipient();
01800
01801 $sOwnerMessage = "Error sending eMail(". $this->getSubject().") to: \n\n";
01802
01803 foreach ( $aRecipients as $aEMail ) {
01804 $sOwnerMessage .= $aEMail[0];
01805 $sOwnerMessage .= ( !empty($aEMail[1]) ) ? ' (' . $aEMail[1] . ')' : '';
01806 $sOwnerMessage .= " \n ";
01807 }
01808 $sOwnerMessage .= "\n\nError : " . $this->getErrorInfo();
01809
01810
01811 $oShop = $this->_getShop();
01812
01813 $blRet = @mail( $oShop->oxshops__oxorderemail->value, "eMail problem in shop!", $sOwnerMessage);
01814
01815 return $blRet;
01816 }
01817
01827 protected function _addUserInfoOrderEMail( $oOrder )
01828 {
01829 return $oOrder;
01830 }
01831
01841 protected function _addUserRegisterEmail( $oUser )
01842 {
01843 return $oUser;
01844 }
01845
01855 protected function _addForgotPwdEmail( $oShop )
01856 {
01857 return $oShop;
01858 }
01859
01869 protected function _addNewsletterDbOptInMail( $oUser )
01870 {
01871 return $oUser;
01872 }
01873
01879 protected function _clearMailer()
01880 {
01881 $this->clearAllRecipients();
01882 $this->clearReplyTos();
01883 $this->clearAttachments();
01884
01885
01886 $this->error_count = 0;
01887 $this->ErrorInfo = '';
01888 }
01889
01897 protected function _setMailParams( $oShop = null )
01898 {
01899 $this->_clearMailer();
01900
01901 if ( !$oShop ) {
01902 $oShop = $this->_getShop();
01903 }
01904
01905 $this->setFrom( $oShop->oxshops__oxorderemail->value, $oShop->oxshops__oxname->getRawValue() );
01906 $this->setSmtp( $oShop );
01907 }
01908
01917 protected function _getShop( $iLangId = null )
01918 {
01919 $myConfig = $this->getConfig();
01920 if ( $iLangId === null ) {
01921 $iLangId = $myConfig->getActiveShop()->getLanguage();
01922 }
01923 $iLangId = oxLang::getInstance()->validateLanguage( $iLangId );
01924
01925 if ( !isset( $this->_aShops[$iLangId] ) ) {
01926 $oShop = oxNew( 'oxshop' );
01927 $oShop->loadInLang( $iLangId, $myConfig->getShopId() );
01928 $this->_aShops[$iLangId] = $myConfig->getActiveView()->addGlobalParams( $oShop );
01929 }
01930
01931 return $this->_aShops[$iLangId];
01932 }
01933
01942 protected function _setSmtpAuthInfo( $sUserName = null, $sUserPassword = null )
01943 {
01944 $this->set( "SMTPAuth", true );
01945 $this->set( "Username", $sUserName );
01946 $this->set( "Password", $sUserPassword );
01947 }
01948
01956 protected function _setSmtpDebug( $blDebug = null )
01957 {
01958 $this->set( "SMTPDebug", $blDebug );
01959 }
01960
01966 protected function _setMailerPluginDir()
01967 {
01968 $this->set( "PluginDir", getShopBasePath() . "core/phpmailer/" );
01969 }
01970
01977 protected function _makeOutputProcessing()
01978 {
01979 $oOutput = oxNew( "oxoutput" );
01980 $this->setBody( $oOutput->process($this->getBody(), "oxemail") );
01981 $this->setAltBody( $oOutput->process($this->getAltBody(), "oxemail") );
01982 $oOutput->processEmail( $this );
01983 }
01984
01990 protected function _sendMail()
01991 {
01992 $blResult = false;
01993 try {
01994 $blResult = parent::send();
01995 } catch( Exception $oEx ) {
01996 }
01997
01998 return $blResult;
01999 }
02000 }