1.Use following code
<?php
$mail = Mage::getModel('core/email');
$mail->setToName('Your Name');
$mail->setToEmail('Youe Email');
$mail->setBody('Mail Text / Mail Content');
$mail->setSubject('Mail Subject');
$mail->setFromEmail('Sender Mail Id');
$mail->setFromName("Msg to Show on Subject");
$mail->setType('html');// YOu can use Html or text as Mail format
try {
$mail->send();
Mage::getSingleton('core/session')->addSuccess('Your request has been sent');
$this->_redirect('');
}
catch (Exception $e) {
Mage::getSingleton('core/session')->addError('Unable to send.');
$this->_redirect('');
}
?>
2.Using email template
First create email template in following location app/locale/en_US/template/email
like demo_test.html
Then add following code in config.xml
<config>
<global>
<template>
<email>
<bd_email_template module="Collegeprogram">
<label>College Ambassadaor Program</label>
<file>demo_test.html</file>
<type>html</type>
</collegeprogram_email_template>
</email>
</template>
</global>
</config>
Use following code in any method
$emailTemplate = Mage::getModel('core/email_template')
->loadDefault('collegeprogram_request_for_college');
$emailTemplateVariables = array();
$emailTemplateVariables['first_var'] = 'Value';
$processedTemplate = $emailTemplate->getProcessedTemplate($emailTemplateVariables);
$emailTemplate->setSenderName('Sender Name');
$emailTemplate->setSenderEmail('d.bhoopendra@gmail.com');
$emailTemplate->setTemplateSubject(Bd Demo Test');
$emailTemplate->send('Email To','Name To', $emailTemplateVariables);
Use {{var first_name}} to retrieve value in template
3.To send mail with attached file, prefer use of Zend_Mail
try{
$mail = new Zend_Mail();
$mail->setFrom("fromemail","fromname");
$mail->addTo("toemail","toname");
$mail->setSubject("subject");
$mail->setBodyHtml(" body text"); // here u also use setBodyText options.
// this is for to set the file format
$at = new Zend_Mime_Part($content);
$at->type = 'application/csv'; // if u have PDF then it would like -> 'application/pdf'
$at->disposition = Zend_Mime::DISPOSITION_INLINE;
$at->encoding = Zend_Mime::ENCODING_8BIT;
$at->filename = $filename;
$mail->addAttachment($at);
$mail->send();
}catch(Exception $e)
{
echo $e->getMassage();
}
来源:http://dbhoopendra.blogspot.com/2012/05/how-to-send-email-in-magento.html#.UIqu9ob-J5Q
参考:Sending Email in Magento
4. install free plugin with magento connect
link here
分享到:
相关推荐
magento 邮件收发插件,magento邮件自动发送.
magento1.9 邮件发送失败解决方法,附带视频教程和图片,文字和修改好的文件,只测试过1.9版本. 其他版本没遇到这个问题
Inchoo Email 有别于ASchroder_SMTPPro的另一款邮件插件 功能较简单 但是好用
亲测好用,发件人可显示设置的邮箱地址,而不是magento的代发地址。将app文件夹内的所有文件,复制到magento安装目录app文件夹中。设置目录:magento后台->system->configuration->ASCHRODER EXTENSIONS->SMTP pro
Chapter 3, Enabling Performance in Magento 2, explains how to configure different types of caching options. In Magento 2, the Full Page Cache (FPC) can be handled by Varnish to give your store a ...
magento的SMTP插件magento的SMTP插件magento的SMTP插件
magento入门原版书.。。The Definitive Guide to Magento.pdf
Chapter 3, Enabling Performance in Magento 2, explains how to configure different types of caching options. In Magento 2, the Full Page Cache (FPC) can be handled by Varnish to give your store a ...
You’ll start by getting a general understanding of what Magento is, why and how you should use it, and whether it is possible and feasible to migrate from an old web store to Magento 2. As you work ...
Apress.The.Definitive.Guide.to.Magento.Dec.2009.pdf Apress于2009重磅推出的Magento上手书籍,原书地址:http://www.apress.com/book/view/9781430272298
实现magento批量发货,针对no tracking code的订单,并保存批量发货的log信息到数据库
magento数据结构分析 magento数据字典
Magento2-编辑订单电子邮件地址 在购买过程中输入错误的电子邮件地址是一个非常常见的错误,尤其是通过电话交易进行订购时。 减少客户每次输错电子邮件时的时间和沮丧感。 使用我们的扩展程序,无需为了更正电子邮件...
magik shoes magento 模板, magento 1.7 模板
Get a hands-on introduction to custom shipping and payment methods ☆ 出版信息:☆ [作者信息] Branko Ajzele [出版机构] Packt Publishing [出版日期] 2013年09月25日 [图书页数] 128页 [图书语言] 英语...
NULL 博文链接:https://justcoding.iteye.com/blog/1886183
深入理解Magento 由精东博客下载下来制作成pdf
Magento插件开发手册 Magento Extension Developers Guide
概述该存储库包含将Magento 2与TurnTo的Social Commerce服务连接的Magento 2扩展。 与Magento社区和企业版2.1.x-2.3.x兼容。安装说明使用Composer安装(推荐) 在您的Magento根安装目录中运行以下命令: composer ...