2011-08-31 6 views
2

나는 내 웹 사이트의 특정 경우에 이메일을 보내는 데 사용할 수있는 Magento 모듈을 만들고 있습니다. 내가 Branko Ajzele에서 자습서를 따르고있어 내가 Send 함수에서 잘못된 응답을받는 이메일을 보내려고 시도 할 때까지 모든 것이 잘 작동하는 것 같다. 다음은 Magento에서 템플릿 이메일 보내기

반환 나는 결과와 함께 사용하고 코드입니다 :

public function sendAction() { 

    /* 
    * Loads the html file named 'custom_email_template1.html' from 
    * app/locale/en_US/template/email/activecodeline_custom_email1.html 
    */ 
    $emailTemplate = Mage::getModel('core/email_template') 
          ->loadDefault('custom_email_template1');         
//  var_dump(Mage::getModel('core/email_template')); 
    //Create an array of variables to assign to template 
    $emailTemplateVariables = array(); 
    $emailTemplateVariables['myvar1'] = 'Branko'; 
    $emailTemplateVariables['myvar2'] = 'Ajzele'; 
    $emailTemplateVariables['myvar3'] = 'ActiveCodeline'; 

    /** 
    * The best part <img src="http://inchoo.net/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> 
    * Opens the activecodeline_custom_email1.html, throws in the variable array 
    * and returns the 'parsed' content that you can use as body of email 
    */ 

    /* 
    * Or you can send the email directly, 
    * note getProcessedTemplate is called inside send() 
    */ 
    $emailTemplate->setSenderName('my name'); 
    $emailTemplate->setSenderEmail('[email protected]'); 
    $emailTemplate->setTemplateSubject('STATUS CHANGED'); 

    var_dump($emailTemplate->send('[email protected]')); 
    echo "<br>"; 
    var_dump($emailTemplate); 

    exit("test"); 

} 

위해서 var_dump ($ emailTemplate를)에 의해 주어진 위해서 var_dump; 아래 그림과 같이 올바르게 모든 정보를 사용하여 객체를 반환 :

bool(false) 
object(Gp_Notify_Model_Email_Template)#82 (19) { ["_templateFilter:protected"]=> NULL ["_preprocessFlag:protected"]=> bool(false) ["_mail:protected"]=> NULL ["_designConfig:protected"]=> NULL ["_emulatedDesignConfig:protected"]=> bool(false) ["_initialEnvironmentInfo:protected"]=> NULL ["_eventPrefix:protected"]=> string(13) "core_abstract" ["_eventObject:protected"]=> string(6) "object" ["_resourceName:protected"]=> string(19) "core/email_template" ["_resource:protected"]=> NULL ["_resourceCollectionName:protected"]=> string(30) "core/email_template_collection" ["_cacheTag:protected"]=> bool(false) ["_dataSaveAllowed:protected"]=> bool(true) ["_isObjectNew:protected"]=> NULL ["_data:protected"]=> array(6) { ["template_type"]=> int(2) ["template_subject"]=> string(14) "STATUS CHANGED" ["template_text"]=> string(208) " 
ActiveCodeline custom email example by Branko Ajzele 

Hi there {{var myvar1}} {{var myvar2}} from {{var myvar3}}. This is just some example template to test custom email module. 
" ["template_id"]=> string(22) "custom_email_template1" ["sender_name"]=> string(7) "my name" ["sender_email"]=> string(15) "[email protected]" } ["_hasDataChanges:protected"]=> bool(true) ["_origData:protected"]=> NULL ["_idFieldName:protected"]=> NULL ["_isDeleted:protected"]=> bool(false) } test 

것은 모든 가고 보이더라도 잘 송신 기능이 false를 반환하는 것입니다 물론 나는 이메일을받을 수 없습니다. 백엔드 또는 다른 구성 에서처럼 잊어 버리는 기능이 있습니까?

---- UPDATE ----

몇 가지 조사 후 내가 거기, 나는 그들이 생각했던 내 젠토 설치에 전혀 자신의 목적지에 도달 아무 이메일 없습니다 그래서 거기에서 시작해야 낸 것을 깨달았다.

나는 이미 백엔드에있는 모든 이메일을 추가했습니다. 로케일 (언어)을 확인하고 영어/미국 (읽었을 때 문제가 될 수 있음)으로 변경했습니다. 조언이 있으십니까?

+0

설치 한 Gp_Notify 모듈은 무엇입니까? 그것은 표준 전자 메일 템플릿 개체를 대체하고 아마도 문제가 될 수 있습니다. –

답변

0

로컬 호스트 또는 라이브 사이트에서 시도하고 있습니까? localhost를 사용하려는 경우 php.ini 파일에서 전자 메일 설정을 정정해야합니다.