Wednesday 28 October 2015

Send contact email programmatically in magento


Send contact email programmatically in magento

$mageFilename = '../app/Mage.php';
require_once $mageFilename;
umask(0);
Mage::app();

$post = array('name'=>'Chandresh','email'=>'chand.4rana@gmail.com','telephone'=>'9222888120','comment'=>'This is testing email');
$postObject = new Varien_Object();
$postObject->setData($post);
$translate = Mage::getSingleton('core/translate');
$mailTemplate = Mage::getModel('core/email_template');
/* @var $mailTemplate Mage_Core_Model_Email_Template */

try{
$mailTemplate->setDesignConfig(array('area' => 'frontend'))
->setReplyTo($post['email'])
->sendTransactional(
Mage::getStoreConfig('contacts/email/email_template'),
Mage::getStoreConfig('contacts/email/sender_email_identity'),
Mage::getStoreConfig('contacts/email/recipient_email'),
null,
array('data' => $postObject)
);
$translate->setTranslateInline(true);
echo Mage::helper('contacts')->__('Your inquiry was submitted and will be responded to as soon as possible. Thank you for contacting us.');

}catch(Exception $e){

echo Mage::helper('contacts')->__('Unable to submit your request. Please, try again later');

}

No comments: