magento 联系人电子邮件附件,未收到附件
magento contact email attachment, no attachment received
我正在尝试创建一个允许客户附加文件的 magento 模块联系页面。我遵循 magephsycho and created my own module however I am receiving blank email. Upon searching on google I found this stackexchange question 的教程并修改了 IndexController.php。我现在收到有内容但没有附件的电子邮件。
我是 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" />
这是我在 app/code/local/Attachment/Eattachment/etc
中保存的 config.xml
<?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 中替换的代码,保存在 app/code/local/Attachment/Eattachment/controllers
if(file_exists($attachmentFilePath)){
mailTemplate->getMail()->createAttachment(
file_get_contents($attachmentFilePath),
Zend_Mime::TYPE_OCTETSTREAM,
Zend_Mime::DISPOSITION_ATTACHMENT,
Zend_Mime::ENCODING_BASE64,
$fileName
);
}
最后,这是在app/etc/modules
上保存的向magento引入模块的config.xml
<?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}}
希望我提供了有用的信息。截至目前,我不知道发生了什么事。我不确定我是否将文件保存在正确的位置。
我的问题是我没有收到联系我们页面中发送的任何电子邮件附件。
谢谢!
我 post 这个问题已经一个月了。在解决这个问题之前,我同时转到了项目的其他阶段。
我从安装的联系我们扩展中发现了问题。
为了解决这个问题,我卸载了扩展并修改了我的代码
修改:
无需在交易电子邮件页面中包含输入字段。这是修改后的代码。
姓名:{{var data.name}}
电子邮件:{{var data.email}}
电话:{{var data.telephone}}
投票问题:{{var data.pollquestions}}
其他指定:{{var data.othersSpecify}}
评论:{{var data.comment}}
我把上面的控制器代码替换成了这个
if(file_exists($attachmentFilePath)){
$fileContents = file_get_contents($attachmentFilePath);
$attachment = $mailTemplate->getMail()->createAttachment($fileContents);
$attachment->filename = $fileName;
}
代码有效,我现在可以接收电子邮件附件了。
希望这对其他人有帮助。
我正在尝试创建一个允许客户附加文件的 magento 模块联系页面。我遵循 magephsycho and created my own module however I am receiving blank email. Upon searching on google I found this stackexchange question 的教程并修改了 IndexController.php。我现在收到有内容但没有附件的电子邮件。
我是 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" />
这是我在 app/code/local/Attachment/Eattachment/etc
中保存的 config.xml<?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 中替换的代码,保存在 app/code/local/Attachment/Eattachment/controllers
if(file_exists($attachmentFilePath)){
mailTemplate->getMail()->createAttachment(
file_get_contents($attachmentFilePath),
Zend_Mime::TYPE_OCTETSTREAM,
Zend_Mime::DISPOSITION_ATTACHMENT,
Zend_Mime::ENCODING_BASE64,
$fileName
);
}
最后,这是在app/etc/modules
上保存的向magento引入模块的config.xml<?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}}
希望我提供了有用的信息。截至目前,我不知道发生了什么事。我不确定我是否将文件保存在正确的位置。
我的问题是我没有收到联系我们页面中发送的任何电子邮件附件。
谢谢!
我 post 这个问题已经一个月了。在解决这个问题之前,我同时转到了项目的其他阶段。
我从安装的联系我们扩展中发现了问题。
为了解决这个问题,我卸载了扩展并修改了我的代码
修改:
无需在交易电子邮件页面中包含输入字段。这是修改后的代码。
姓名:{{var data.name}} 电子邮件:{{var data.email}} 电话:{{var data.telephone}} 投票问题:{{var data.pollquestions}} 其他指定:{{var data.othersSpecify}} 评论:{{var data.comment}}
我把上面的控制器代码替换成了这个
if(file_exists($attachmentFilePath)){ $fileContents = file_get_contents($attachmentFilePath);
$attachment = $mailTemplate->getMail()->createAttachment($fileContents); $attachment->filename = $fileName; }
代码有效,我现在可以接收电子邮件附件了。
希望这对其他人有帮助。