为什么在配置/系统/邮件发送设置中无法为您的smtp服务器指定用户名和密码?以编程方式在Magento中发送电子邮件失败
要解决这个问题,你需要进行更改,以在这个岗位概述getMail(): http://www.magentocommerce.com/boards/viewthread/1073/P30/
我想要做的东西很简单:
- 创建一个电子邮件模板
- 不必在任何配置文件中引用该模板。
- 供应值在模板中替换任何标签
- - 供给收件人的电子邮件地址
- 编程方式使用上述
定义的模板发送电子邮件供应其它位从地址,像
所以第一步 - 创建一个模板。
- 在配置/交易电子邮件我相信我应该看到一个模板列表。我什么也没看见。但是如果我添加一个新模板,我可以从模板列表中进行选择。
- 给模板名称“Bob”。
- 添加几瓦尔到模板:
myvar1 = {{VAR myvar1}}
myvar2 = {{VAR myvar2}}
- 保存模板;它的Id为1.
现在通过编程方式从控制器操作发送电子邮件:
- 无需更改Mime.php中的LINEEND,因为它已在版本1.4中设置为\ n。 2.0
- 因为在这个岗位规定进行更改,getMail()中的template.php: - 写在控制器动作代码发送电子邮件http://www.magentocommerce.com/boards/viewthread/1073/P30/
:
This returns nothing:
$emailTemplate = Mage::getModel('core/email_template')->loadDefault('no matter what goes here emailTemplate is not set');
This does return an email template:
$emailTemplate = Mage::getModel('core/email_template')->loadByCode('Bob');
but the call to send below fails:
$emailTemplate->setSenderEmail('[email protected]');
$emailTemplate->setSenderName('Steve');
$emailTemplateVariables = array();
$emailTemplateVariables['myvar1'] = 'TestValue1';
$emailTemplateVariables['myvar2'] = 'TestValue2';
// $processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables); -- this returns nothing
$emailTemplate->send('[email protected]','John', $emailTemplateVariables);
In the system.log I get the warning below, and no e-mail ever arrives.
Warning: stream_socket_enable_crypto() [<a href='streams.crypto'>streams.crypto</a>]: this stream does not support SSL/crypto in C:\Applications\Apache Software Foundation\Apache2.2\htdocs\magento\lib\Zend\Mail\Protocol\Smtp.php on line 206
我应该使用loadByCode?我希望有一些有价值的文档(loadByCode的帮助是“通过代码加载模板”!!)。我应该使用send,sendTransactional?哦,一点质量文件。
感谢