2015-05-29 134 views
1

我想创建一个允许客户附加文件的magento模块联系页面。我遵循magephsycho这个教程,并创建了自己的模块,但是我收到空白的电子邮件。在google上搜索时,我发现这个stackexchange question并修改了IndexController.php。我现在收到带有内容但没有附件的电子邮件。magento联系电子邮件附件,没有收到附件

我是新来的magento,我不知道什么是错的。

这是我的html代码:

<form action="<?php echo $this->getFormAction(); ?>" id="contactForm" method="post" enctype="multipart/form-data"> 

<input name="MAX_FILE_SIZE" type="hidden" value="2000000" /> 
<input name="fileattachment" id="fileattachment" title="<?php echo Mage::helper('contacts')->__('FileAttachment') ?>" placeholder="<?php echo Mage::helper('contacts')->__('Upload File') ?>" value="fileattachment" class="input-text" type="file" /> 

这是我的config.xml保存在应用程序/代码/本地/附件/ Eattachment /等

<?xml version="1.0"?> 
<config> 
    <frontend> 
     <routers> 
      <contacts> 
       <args> 
        <modules> 
         <Attachment_Eattachment before="Mage_Contacts">Attachment_Eattachment</Attachment_Eattachment> 
        </modules> 
       </args> 
      </contacts> 
     </routers> 
    </frontend> 
</config> 

这是我在更换代码是保存在应用程序/代码IndexController.php /本地/附件/ Eattachment /控制器

if(file_exists($attachmentFilePath)){ 
    mailTemplate->getMail()->createAttachment(
     file_get_contents($attachmentFilePath), 
     Zend_Mime::TYPE_OCTETSTREAM, 
     Zend_Mime::DISPOSITION_ATTACHMENT, 
     Zend_Mime::ENCODING_BASE64, 
     $fileName 
    ); 
} 

最后,这是叔他说config.xml文件介绍了模块的Magento保存在应用的/ etc /模块

<?xml version="1.0"?> 
<config> 
    <modules> 
     <Attachment_Eattachment> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Attachment_Eattachment> 
    </modules> 
</config> 

更新:这是从管理事务电子邮件

Name: {{var data.name}} 
Email: {{var data.email}} 
Telephone: {{var data.telephone}} 
PollQuestions: {{var data.pollquestions}} 
OtherSpecify: {{var data.othersSpecify}} 
FileAttachment: {{var data.fileattachment}} 
Comment: {{var data.comment}} 

我希望我给有用信息的代码。截至目前我不知道发生了什么事。我不确定是否将文件保存在适当的位置。

我的问题是我没有收到联系我们页面发送的任何电子邮件附件。

谢谢!

回答

0

我发表了这个问题已经有一个月了。同时,在我解决这个问题之前,我转到了项目的其他阶段。

我发现从我安装的联系我们扩展的问题。

为了解决这个问题,我卸载了该扩展和修改我的代码

变型:

  1. 无需包括异动电子邮件页面中输入字段。这是修改后的代码。

    名称:{{VAR data.name}} 电子邮件:{{VAR data.email}} 电话:{{VAR data.telephone}} PollQuestions:{{VAR data.pollquestions}} OtherSpecify: {{var data.othersSpecify}} 评论:{{var data。注释}}

  2. 我更换控制器代码从上方到该

    如果(file_exists($ attachmentFilePath)){$ = fileContents的file_get_contents($ attachmentFilePath);

       $attachment = $mailTemplate->getMail()->createAttachment($fileContents); 
    
           $attachment->filename = $fileName; 
          } 
    

代码工作,现在我可以接收电子邮件附件。

希望这可以帮助别人。