Version Notes
Elastic Email is a mail relay service. That is, instead of your website sending mail via its own SMTP server, outgoing email is directed through the Elastic Email service and out onto the internet. This module provides plug n' play integration with the Elastic Email service.
Download this release
Release Info
Developer | Magento Core Team |
Extension | Elastic_Email_Extension |
Version | 1.0 |
Comparing to | |
See all releases |
Version 1.0
- app/code/local/Apptha/Elasticemail/Block/Adminhtml/Account.php +23 -0
- app/code/local/Apptha/Elasticemail/Block/Adminhtml/Account/Grid.php +35 -0
- app/code/local/Apptha/Elasticemail/Block/Adminhtml/Transaction.php +23 -0
- app/code/local/Apptha/Elasticemail/Block/Adminhtml/Transaction/Grid.php +85 -0
- app/code/local/Apptha/Elasticemail/Block/Adminhtml/Transaction/Renderer/Status.php +68 -0
- app/code/local/Apptha/Elasticemail/Block/Elasticemail.php +26 -0
- app/code/local/Apptha/Elasticemail/Helper/Data.php +6 -0
- app/code/local/Apptha/Elasticemail/Model/Email.php +71 -0
- app/code/local/Apptha/Elasticemail/Model/Email/Template.php +86 -0
- app/code/local/Apptha/Elasticemail/Model/Mysql4/Transaction.php +19 -0
- app/code/local/Apptha/Elasticemail/Model/Mysql4/Transaction/Collection.php +19 -0
- app/code/local/Apptha/Elasticemail/Model/Newsletter/Queue.php +156 -0
- app/code/local/Apptha/Elasticemail/Model/Newsletter/Template.php +168 -0
- app/code/local/Apptha/Elasticemail/Model/Transaction.php +20 -0
- app/code/local/Apptha/Elasticemail/controllers/Adminhtml/AccountController.php +30 -0
- app/code/local/Apptha/Elasticemail/controllers/Adminhtml/TransactionController.php +207 -0
- app/code/local/Apptha/Elasticemail/controllers/IndexController.php +19 -0
- app/code/local/Apptha/Elasticemail/etc/adminhtml.xml +47 -0
- app/code/local/Apptha/Elasticemail/etc/config.xml +108 -0
- app/code/local/Apptha/Elasticemail/etc/system.xml +109 -0
- app/code/local/Apptha/Elasticemail/sql/elasticemail_setup/mysql4-install-0.1.0.php +21 -0
- app/design/adminhtml/default/default/layout/elasticemail.xml +8 -0
- app/design/adminhtml/default/default/template/elasticemail/account.phtml +50 -0
- app/etc/modules/Apptha_Elasticemail.xml +9 -0
- package.xml +18 -0
- skin/adminhtml/default/default/elasticemail.css +6 -0
app/code/local/Apptha/Elasticemail/Block/Adminhtml/Account.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Account.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Block_Adminhtml_Account extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
$this->_controller = 'adminhtml_account';
|
17 |
+
$this->_blockGroup = 'elasticemail';
|
18 |
+
$this->_headerText = Mage::helper('elasticemail')->__('Account Dashboard');
|
19 |
+
parent::__construct();
|
20 |
+
$this->_removeButton('add');
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
app/code/local/Apptha/Elasticemail/Block/Adminhtml/Account/Grid.php
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: grid.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Block_Adminhtml_Account_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
parent::__construct();
|
17 |
+
$this->setTemplate('elasticemail/account.phtml');
|
18 |
+
}
|
19 |
+
|
20 |
+
//get credit details from elastice email account
|
21 |
+
public function getCredit() {
|
22 |
+
$ch = curl_init();
|
23 |
+
$url = 'https://api.elasticemail.com/mailer/account-details?username=' . Mage::getStoreConfig('elasticemail/smtp/user') . '&api_key=' . Mage::getStoreConfig('elasticemail/smtp/api');
|
24 |
+
$ch = curl_init($url);
|
25 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
26 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
27 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
28 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
29 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1');
|
30 |
+
$r = curl_exec($ch);
|
31 |
+
return $r;
|
32 |
+
}
|
33 |
+
|
34 |
+
}
|
35 |
+
|
app/code/local/Apptha/Elasticemail/Block/Adminhtml/Transaction.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Transaction.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Block_Adminhtml_Transaction extends Mage_Adminhtml_Block_Widget_Grid_Container {
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
$this->_controller = 'adminhtml_transaction';
|
17 |
+
$this->_blockGroup = 'elasticemail';
|
18 |
+
$this->_headerText = Mage::helper('elasticemail')->__('Transaction Manager');
|
19 |
+
parent::__construct();
|
20 |
+
$this->_removeButton('add');
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
app/code/local/Apptha/Elasticemail/Block/Adminhtml/Transaction/Grid.php
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Grid.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Block_Adminhtml_Transaction_Grid extends Mage_Adminhtml_Block_Widget_Grid {
|
14 |
+
|
15 |
+
public function __construct() {
|
16 |
+
parent::__construct();
|
17 |
+
$this->setId('elasticemailGrid');
|
18 |
+
$this->setDefaultSort('transaction_id');
|
19 |
+
$this->setDefaultDir('DESC');
|
20 |
+
$this->setSaveParametersInSession(true);
|
21 |
+
}
|
22 |
+
|
23 |
+
protected function _prepareCollection() {
|
24 |
+
$collection = Mage::getModel('elasticemail/transaction')->getCollection();
|
25 |
+
$this->setCollection($collection);
|
26 |
+
return parent::_prepareCollection();
|
27 |
+
}
|
28 |
+
|
29 |
+
protected function _prepareColumns() {
|
30 |
+
$this->addColumn('type', array(
|
31 |
+
'header' => Mage::helper('elasticemail')->__('Email Type'),
|
32 |
+
'align' => 'left',
|
33 |
+
'index' => 'type',
|
34 |
+
));
|
35 |
+
$this->addColumn('status', array(
|
36 |
+
'header' => Mage::helper('elasticemail')->__('Status'),
|
37 |
+
'align' => 'left',
|
38 |
+
'index' => 'response_id',
|
39 |
+
'renderer' => 'Apptha_Elasticemail_Block_Adminhtml_Transaction_Renderer_Status',
|
40 |
+
));
|
41 |
+
|
42 |
+
|
43 |
+
$this->addColumn('created_time', array(
|
44 |
+
'header' => Mage::helper('elasticemail')->__('Send Time'),
|
45 |
+
'align' => 'left',
|
46 |
+
'index' => 'created_time',
|
47 |
+
));
|
48 |
+
|
49 |
+
$this->addColumn('action',
|
50 |
+
array(
|
51 |
+
'header' => Mage::helper('elasticemail')->__('Action'),
|
52 |
+
'width' => '100',
|
53 |
+
'type' => 'action',
|
54 |
+
'getter' => 'getId',
|
55 |
+
'actions' => array(
|
56 |
+
array(
|
57 |
+
'caption' => Mage::helper('elasticemail')->__('Download Csv'),
|
58 |
+
'url' => array('base' => '*/*/status'),
|
59 |
+
'field' => 'id'
|
60 |
+
)
|
61 |
+
),
|
62 |
+
'filter' => false,
|
63 |
+
'sortable' => false,
|
64 |
+
'index' => 'stores',
|
65 |
+
'is_system' => true,
|
66 |
+
));
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
return parent::_prepareColumns();
|
71 |
+
}
|
72 |
+
|
73 |
+
protected function _prepareMassaction() {
|
74 |
+
$this->setMassactionIdField('transaction_id');
|
75 |
+
$this->getMassactionBlock()->setFormFieldName('elasticemail');
|
76 |
+
|
77 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
78 |
+
'label' => Mage::helper('elasticemail')->__('Delete'),
|
79 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
80 |
+
'confirm' => Mage::helper('elasticemail')->__('Are you sure?')
|
81 |
+
));
|
82 |
+
return $this;
|
83 |
+
}
|
84 |
+
|
85 |
+
}
|
app/code/local/Apptha/Elasticemail/Block/Adminhtml/Transaction/Renderer/Status.php
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Status.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Block_Adminhtml_Transaction_Renderer_Status extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
|
14 |
+
|
15 |
+
//get email staus from elastice email account using response id.
|
16 |
+
public function render(Varien_Object $row) {
|
17 |
+
|
18 |
+
$responseId = trim($row->getData($this->getColumn()->getIndex()));
|
19 |
+
$ch = curl_init();
|
20 |
+
$url = "https://api.elasticemail.com/mailer/status/$responseId?showstats=true";
|
21 |
+
$ch = curl_init($url);
|
22 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
23 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
24 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
25 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
26 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1');
|
27 |
+
$result = curl_exec($ch);
|
28 |
+
$doc = new DOMDocument();
|
29 |
+
$doc->loadXML($result);
|
30 |
+
|
31 |
+
//recipients
|
32 |
+
$recipients = $doc->getElementsByTagName("recipients");
|
33 |
+
$recipients = $recipients->item(0)->nodeValue;
|
34 |
+
|
35 |
+
$status = 'Recipients - ' . $recipients . ' | ';
|
36 |
+
//unsubscribed
|
37 |
+
$unsubscribed = $doc->getElementsByTagName("unsubscribed");
|
38 |
+
$unsubscribed = $unsubscribed->item(0)->nodeValue;
|
39 |
+
$status .= ' Unsubscribed - ' . $unsubscribed . ' | ';
|
40 |
+
//pending
|
41 |
+
$pending = $doc->getElementsByTagName("pending");
|
42 |
+
$pending = $pending->item(0)->nodeValue;
|
43 |
+
$status .= 'Pending - ' . $pending . ' | ';
|
44 |
+
//opened
|
45 |
+
$opened = $doc->getElementsByTagName("opened");
|
46 |
+
$opened = $opened->item(0)->nodeValue;
|
47 |
+
$status .= 'Opened - ' . $opened . ' | ';
|
48 |
+
//failed
|
49 |
+
$failed = $doc->getElementsByTagName("failed");
|
50 |
+
$failed = $failed->item(0)->nodeValue;
|
51 |
+
$status .= 'Failed - ' . $failed . ' | ';
|
52 |
+
//delivered
|
53 |
+
$delivered = $doc->getElementsByTagName("delivered");
|
54 |
+
$delivered = $delivered->item(0)->nodeValue;
|
55 |
+
$status .= 'Delivered - ' . $delivered . ' | ';
|
56 |
+
|
57 |
+
//clicked
|
58 |
+
$clicked = $doc->getElementsByTagName("clicked");
|
59 |
+
$clicked = $clicked->item(0)->nodeValue;
|
60 |
+
$status .= 'Clicked - ' . $clicked . ' | ';
|
61 |
+
//abuser
|
62 |
+
$abusereports = $doc->getElementsByTagName("abusereports");
|
63 |
+
$abusereports = $abusereports->item(0)->nodeValue;
|
64 |
+
$status .= 'Abusereports - ' . $abusereports;
|
65 |
+
return $status;
|
66 |
+
}
|
67 |
+
|
68 |
+
}
|
app/code/local/Apptha/Elasticemail/Block/Elasticemail.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Elasticemail.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Block_Elasticemail extends Mage_Core_Block_Template {
|
14 |
+
|
15 |
+
public function _prepareLayout() {
|
16 |
+
return parent::_prepareLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
public function getElasticemail() {
|
20 |
+
if (!$this->hasData('elasticemail')) {
|
21 |
+
$this->setData('elasticemail', Mage::registry('elasticemail'));
|
22 |
+
}
|
23 |
+
return $this->getData('elasticemail');
|
24 |
+
}
|
25 |
+
|
26 |
+
}
|
app/code/local/Apptha/Elasticemail/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Apptha_Elasticemail_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Apptha/Elasticemail/Model/Email.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Email.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Model_Email extends Mage_Core_Model_Email {
|
14 |
+
|
15 |
+
//overrite core email send function
|
16 |
+
public function send() {
|
17 |
+
//get the details from config
|
18 |
+
$apiUsername = Mage::getStoreConfig('elasticemail/smtp/user');
|
19 |
+
$apiKey = Mage::getStoreConfig('elasticemail/smtp/api');
|
20 |
+
$from = Mage::getStoreConfig('elasticemail/sender/sender');
|
21 |
+
$fromName = Mage::getStoreConfig('elasticemail/sender/sendername');
|
22 |
+
$to = $this->getToEmail();
|
23 |
+
|
24 |
+
$body = $this->getBody();
|
25 |
+
$subject = $this->getSubject();
|
26 |
+
$res = "";
|
27 |
+
|
28 |
+
$data = "username=" . urlencode($apiUsername);
|
29 |
+
$data .= "&api_key=" . urlencode($apiKey);
|
30 |
+
$data .= "&from=" . urlencode($from);
|
31 |
+
$data .= "&from_name=" . urlencode($fromName);
|
32 |
+
$data .= "&to=" . urlencode($to);
|
33 |
+
$data .= "&subject=" . urlencode($subject);
|
34 |
+
if (strtolower($this->getType()) == 'html') {
|
35 |
+
$data .= "&body_html=" . urlencode($body);
|
36 |
+
} else {
|
37 |
+
$data .= "&body_text=" . urlencode($body);
|
38 |
+
}
|
39 |
+
|
40 |
+
$header = "POST /mailer/send HTTP/1.0\r\n";
|
41 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
42 |
+
$header .= "Content-Length: " . strlen($data) . "\r\n\r\n";
|
43 |
+
$fp = fsockopen('ssl://api.elasticemail.com', 443, $errno, $errstr, 30);
|
44 |
+
|
45 |
+
if (!$fp)
|
46 |
+
return $this;
|
47 |
+
else {
|
48 |
+
fputs($fp, $header . $data);
|
49 |
+
while (!feof($fp)) {
|
50 |
+
$res .= fread($fp, 1024);
|
51 |
+
}
|
52 |
+
fclose($fp);
|
53 |
+
$chars = preg_split('/Content-Length:/', $res, -1);
|
54 |
+
$result = explode("36", $chars[1]);
|
55 |
+
$responsId = $result[1];
|
56 |
+
if ($responsId != '0') {
|
57 |
+
$model = Mage::getModel('elasticemail/transaction');
|
58 |
+
$model->setResponseId($responsId);
|
59 |
+
$model->setType('Normal');
|
60 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
61 |
+
$model->setCreatedTime(now())->setUpdateTime(now());
|
62 |
+
} else {
|
63 |
+
$model->setUpdateTime(now());
|
64 |
+
}
|
65 |
+
|
66 |
+
$model->save();
|
67 |
+
}
|
68 |
+
return $this;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
}
|
app/code/local/Apptha/Elasticemail/Model/Email/Template.php
ADDED
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Template.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Model_Email_Template extends Mage_Core_Model_Email_Template {
|
14 |
+
|
15 |
+
//overrite core newsletter send function
|
16 |
+
public function send($email, $name=null, array $variables = array()) {
|
17 |
+
//get the details from config
|
18 |
+
$apiUsername = Mage::getStoreConfig('elasticemail/smtp/user');
|
19 |
+
$apiKey = Mage::getStoreConfig('elasticemail/smtp/api');
|
20 |
+
$from = Mage::getStoreConfig('elasticemail/sender/sender');
|
21 |
+
$fromName = Mage::getStoreConfig('elasticemail/sender/sendername');
|
22 |
+
$replyTo = Mage::getStoreConfig('elasticemail/sender/reply');
|
23 |
+
$replytoName = Mage::getStoreConfig('elasticemail/sender/replyname');
|
24 |
+
if (is_array($email)) {
|
25 |
+
foreach ($email as $emailOne) {
|
26 |
+
$to .= $emailOne . ';';
|
27 |
+
}
|
28 |
+
} else {
|
29 |
+
$to = $email;
|
30 |
+
}
|
31 |
+
$body = $this->getProcessedTemplate($variables, true);
|
32 |
+
$subject = $this->getProcessedTemplateSubject($variables);
|
33 |
+
$res = "";
|
34 |
+
|
35 |
+
$data = "username=" . urlencode($apiUsername);
|
36 |
+
$data .= "&api_key=" . urlencode($apiKey);
|
37 |
+
$data .= "&from=" . urlencode($from);
|
38 |
+
$data .= "&from_name=" . urlencode($fromName);
|
39 |
+
$data .= "&to=" . urlencode($to);
|
40 |
+
$data .= "&subject=" . urlencode($subject);
|
41 |
+
if ($this->isPlain()) {
|
42 |
+
$data .= "&body_text=" . urlencode($body);
|
43 |
+
} else {
|
44 |
+
$data .= "&body_html=" . urlencode($body);
|
45 |
+
}
|
46 |
+
if ($replyTo != '') {
|
47 |
+
$data .= "&reply_to=" . urlencode($replyTo);
|
48 |
+
}
|
49 |
+
if ($replytoName != '') {
|
50 |
+
$data .= "&reply_to_name=" . urlencode($replytoName);
|
51 |
+
}
|
52 |
+
$header = "POST /mailer/send HTTP/1.0\r\n";
|
53 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
54 |
+
$header .= "Content-Length: " . strlen($data) . "\r\n\r\n";
|
55 |
+
$fp = fsockopen('ssl://api.elasticemail.com', 443, $errno, $errstr, 30);
|
56 |
+
|
57 |
+
if (!$fp)
|
58 |
+
return false;
|
59 |
+
else {
|
60 |
+
|
61 |
+
fputs($fp, $header . $data);
|
62 |
+
while (!feof($fp)) {
|
63 |
+
$res .= fread($fp, 1024);
|
64 |
+
}
|
65 |
+
|
66 |
+
fclose($fp);
|
67 |
+
|
68 |
+
$chars = preg_split('/Content-Length:/', $res, -1);
|
69 |
+
$result = explode("36", $chars[1]);
|
70 |
+
$responsId = $result[1];
|
71 |
+
if ($responsId != '0') {
|
72 |
+
$model = Mage::getModel('elasticemail/transaction');
|
73 |
+
$model->setResponseId($responsId);
|
74 |
+
$model->setType('Normal');
|
75 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
76 |
+
$model->setCreatedTime(now())->setUpdateTime(now());
|
77 |
+
} else {
|
78 |
+
$model->setUpdateTime(now());
|
79 |
+
}
|
80 |
+
$model->save();
|
81 |
+
}
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
app/code/local/Apptha/Elasticemail/Model/Mysql4/Transaction.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @name Elastice Email.
|
4 |
+
* @version 1.0: Transaction.php$
|
5 |
+
* @since Magento
|
6 |
+
* @package Apptha
|
7 |
+
* @subpackage Elastice Email
|
8 |
+
* @author vasanth
|
9 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
10 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
11 |
+
*/
|
12 |
+
class Apptha_Elasticemail_Model_Mysql4_Transaction extends Mage_Core_Model_Mysql4_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
// Note that the elasticemail_id refers to the key field in your database table.
|
17 |
+
$this->_init('elasticemail/transaction', 'transaction_id');
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Apptha/Elasticemail/Model/Mysql4/Transaction/Collection.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @name Elastice Email.
|
4 |
+
* @version 1.0: Collection.php$
|
5 |
+
* @since Magento
|
6 |
+
* @package Apptha
|
7 |
+
* @subpackage Elastice Email
|
8 |
+
* @author vasanth
|
9 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
10 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
11 |
+
*/
|
12 |
+
class Apptha_Elasticemail_Model_Mysql4_Transaction_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
13 |
+
{
|
14 |
+
public function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('elasticemail/transaction');
|
18 |
+
}
|
19 |
+
}
|
app/code/local/Apptha/Elasticemail/Model/Newsletter/Queue.php
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Queue.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Model_Newsletter_Queue extends Mage_Newsletter_Model_Queue {
|
14 |
+
|
15 |
+
//overrite core newsletter queue sendPerSubscriber function
|
16 |
+
public function sendPerSubscriber($count=20, array $additionalVariables=array()) {
|
17 |
+
|
18 |
+
if ($this->getQueueStatus() != self::STATUS_SENDING
|
19 |
+
&& ($this->getQueueStatus() != self::STATUS_NEVER && $this->getQueueStartAt())
|
20 |
+
) {
|
21 |
+
return $this;
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($this->getSubscribersCollection()->getSize() == 0) {
|
25 |
+
$this->_finishQueue();
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
$collection = $this->getSubscribersCollection()
|
30 |
+
->useOnlyUnsent()
|
31 |
+
->showCustomerInfo()
|
32 |
+
->setPageSize($count)
|
33 |
+
->setCurPage(1)
|
34 |
+
->load();
|
35 |
+
|
36 |
+
$bodyText = $this->getNewsletterText();
|
37 |
+
/* @var $sender Mage_Core_Model_Email_Template */
|
38 |
+
$bodyHTML = $this->getNewsletterText();
|
39 |
+
//subject
|
40 |
+
$subject = $this->getNewsletterSubject();
|
41 |
+
//from email
|
42 |
+
$senderEmail = Mage::getStoreConfig('elasticemail/sender/sender');
|
43 |
+
//from name
|
44 |
+
$senderName = Mage::getStoreConfig('elasticemail/sender/sendername');
|
45 |
+
|
46 |
+
|
47 |
+
$csv = '"ToMail","Name"' . "\n";
|
48 |
+
|
49 |
+
foreach ($collection->getItems() as $item) {
|
50 |
+
|
51 |
+
$csv .= '"' . $item->getSubscriberEmail() . '","' . $item->getSubscriberFullName() . '"' . "\n";
|
52 |
+
}
|
53 |
+
|
54 |
+
$successSend = $this->mailMerge($csv, $senderEmail, $senderName, $subject, $bodyText, $bodyHTML);
|
55 |
+
|
56 |
+
foreach ($collection->getItems() as $item) {
|
57 |
+
if ($successSend) {
|
58 |
+
$item->received($this);
|
59 |
+
} else {
|
60 |
+
$problem = Mage::getModel('newsletter/problem');
|
61 |
+
$notification = Mage::helper('newsletter')->__('Please refer to exeption.log');
|
62 |
+
$problem->addSubscriberData($item)
|
63 |
+
->addQueueData($this)
|
64 |
+
->addErrorData(new Exception($notification))
|
65 |
+
->save();
|
66 |
+
$item->received($this);
|
67 |
+
}
|
68 |
+
}
|
69 |
+
if (count($collection->getItems()) < $count - 1 || count($collection->getItems()) == 0) {
|
70 |
+
$this->_finishQueue();
|
71 |
+
}
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
|
75 |
+
//if mail contain any attachment
|
76 |
+
function uploadAttachment($content, $fileName, $userName, $apiKey) {
|
77 |
+
|
78 |
+
$res = "";
|
79 |
+
$header = "PUT /attachments/upload?username=" . urlencode($userName) . "&api_key=" . urlencode($apiKey) . "&file=" . urlencode($fileName) . " HTTP/1.0\r\n";
|
80 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
81 |
+
$header .= "Content-Length: " . strlen($content) . "\r\n\r\n";
|
82 |
+
$fp = @fsockopen("ssl://api.elasticemail.com", 443, $errno, $errstr, 30);
|
83 |
+
if (!$fp) {
|
84 |
+
return "ERROR. Could not open connection";
|
85 |
+
} else {
|
86 |
+
fputs($fp, $header . $content);
|
87 |
+
while (!feof($fp)) {
|
88 |
+
$res .= fread($fp, 1024);
|
89 |
+
}
|
90 |
+
fclose($fp);
|
91 |
+
}
|
92 |
+
return $res;
|
93 |
+
}
|
94 |
+
|
95 |
+
//function for sending mail via elastice email
|
96 |
+
function mailMerge($csv, $from, $fromName, $subject, $bodyText, $bodyHTML=NULL) {
|
97 |
+
|
98 |
+
//get the details from config
|
99 |
+
$userName = Mage::getStoreConfig('elasticemail/smtp/user');
|
100 |
+
$apiKey = Mage::getStoreConfig('elasticemail/smtp/api');
|
101 |
+
$replyTo = Mage::getStoreConfig('elasticemail/sender/reply');
|
102 |
+
$replytoName = Mage::getStoreConfig('elasticemail/sender/replyname');
|
103 |
+
|
104 |
+
$csvName = 'mailmerge' . rand(100000, 999999) . '.csv';
|
105 |
+
$this->uploadAttachment($csv, $csvName, $userName, $apiKey);
|
106 |
+
|
107 |
+
$res = "";
|
108 |
+
$data = "username=" . urlencode($userName);
|
109 |
+
$data .= "&api_key=" . urlencode($apiKey);
|
110 |
+
$data .= "&from=" . urlencode($from);
|
111 |
+
$data .= "&from_name=" . urlencode($fromName);
|
112 |
+
$data .= "&subject=" . urlencode($subject);
|
113 |
+
$data .= "&data_source=" . urlencode($csvName);
|
114 |
+
if ($bodyHTML)
|
115 |
+
$data .= "&body_html=" . urlencode($bodyHTML);
|
116 |
+
if ($bodyText)
|
117 |
+
$data .= "&body_text=" . urlencode($bodyText);
|
118 |
+
if ($replyTo != '') {
|
119 |
+
$data .= "&reply_to=" . urlencode($replyTo);
|
120 |
+
}
|
121 |
+
if ($replytoName != '') {
|
122 |
+
$data .= "&reply_to_name=" . urlencode($replytoName);
|
123 |
+
}
|
124 |
+
$header = "POST /mailer/send HTTP/1.0\r\n";
|
125 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
126 |
+
$header .= "Content-Length: " . strlen($data) . "\r\n\r\n";
|
127 |
+
$fp = @fsockopen('ssl://api.elasticemail.com', 443, $errno, $errstr, 30);
|
128 |
+
if (!$fp) {
|
129 |
+
return false;
|
130 |
+
} else {
|
131 |
+
fputs($fp, $header . $data);
|
132 |
+
while (!feof($fp)) {
|
133 |
+
$res .= fread($fp, 1024);
|
134 |
+
}
|
135 |
+
fclose($fp);
|
136 |
+
|
137 |
+
$chars = preg_split('/Content-Length:/', $res, -1);
|
138 |
+
$result = explode("36", $chars[1]);
|
139 |
+
$responsId = $result[1];
|
140 |
+
if ($responsId != '0') {
|
141 |
+
$model = Mage::getModel('elasticemail/transaction');
|
142 |
+
$model->setResponseId($responsId);
|
143 |
+
$model->setType('News Letter');
|
144 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
145 |
+
$model->setCreatedTime(now())->setUpdateTime(now());
|
146 |
+
} else {
|
147 |
+
$model->setUpdateTime(now());
|
148 |
+
}
|
149 |
+
$model->save();
|
150 |
+
return true;
|
151 |
+
}
|
152 |
+
}
|
153 |
+
return true;
|
154 |
+
}
|
155 |
+
|
156 |
+
}
|
app/code/local/Apptha/Elasticemail/Model/Newsletter/Template.php
ADDED
@@ -0,0 +1,168 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Template.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Model_Newsletter_Template extends Mage_Newsletter_Model_Template {
|
14 |
+
|
15 |
+
//overrite core newsletter send function
|
16 |
+
public function send($subscriber, array $variables = array(), $name=null, Mage_Newsletter_Model_Queue $queue=null) {
|
17 |
+
|
18 |
+
if (!$this->isValidForSend()) {
|
19 |
+
return false;
|
20 |
+
}
|
21 |
+
//get email and name
|
22 |
+
$email = '';
|
23 |
+
if ($subscriber instanceof Mage_Newsletter_Model_Subscriber) {
|
24 |
+
$email = $subscriber->getSubscriberEmail();
|
25 |
+
if (is_null($name) && ($subscriber->hasCustomerFirstname() || $subscriber->hasCustomerLastname())) {
|
26 |
+
$name = $subscriber->getCustomerFirstname() . ' ' . $subscriber->getCustomerLastname();
|
27 |
+
}
|
28 |
+
} else {
|
29 |
+
$email = (string) $subscriber;
|
30 |
+
}
|
31 |
+
$csv = '"ToMail","Name"' . "\n";
|
32 |
+
if (is_array($email)) {
|
33 |
+
foreach ($email as $emailOne) {
|
34 |
+
$csv .= '"' . $emailOne . ',"' . $name . '""' . "\n";
|
35 |
+
}
|
36 |
+
} else {
|
37 |
+
$csv .= '"' . $email . '"' . "\n";
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
if (Mage::getStoreConfigFlag(Mage_Newsletter_Model_Subscriber::XML_PATH_SENDING_SET_RETURN_PATH)) {
|
42 |
+
// This is important for SPAM I think, what value should it be?
|
43 |
+
$returnPath = Mage::getStoreConfig('elasticemail/sender/sender');
|
44 |
+
}
|
45 |
+
|
46 |
+
//body
|
47 |
+
$text = $this->getProcessedTemplate($variables, true);
|
48 |
+
if ($this->isPlain()) {
|
49 |
+
$bodyText = $text;
|
50 |
+
} else {
|
51 |
+
$bodyHTML = $text;
|
52 |
+
}
|
53 |
+
//subject
|
54 |
+
$subject = $this->getProcessedTemplateSubject($variables);
|
55 |
+
//from email
|
56 |
+
$senderEmail = Mage::getStoreConfig('elasticemail/sender/sender');
|
57 |
+
//from name
|
58 |
+
$senderName = Mage::getStoreConfig('elasticemail/sender/sendername');
|
59 |
+
|
60 |
+
try {
|
61 |
+
Mage::log('About to send email');
|
62 |
+
$this->mailMerge($csv, $senderEmail, $senderName, $subject, $bodyText, $bodyHTML);
|
63 |
+
Mage::log('Finished sending email');
|
64 |
+
if (!is_null($queue)) {
|
65 |
+
$subscriber->received($queue);
|
66 |
+
}
|
67 |
+
} catch (Exception $e) {
|
68 |
+
|
69 |
+
if ($subscriber instanceof Mage_Newsletter_Model_Subscriber) {
|
70 |
+
// If letter sent for subscriber, we create a problem report entry
|
71 |
+
$problem = Mage::getModel('newsletter/problem');
|
72 |
+
$problem->addSubscriberData($subscriber);
|
73 |
+
if (!is_null($queue)) {
|
74 |
+
$problem->addQueueData($queue);
|
75 |
+
}
|
76 |
+
$problem->addErrorData($e);
|
77 |
+
$problem->save();
|
78 |
+
|
79 |
+
if (!is_null($queue)) {
|
80 |
+
$subscriber->received($queue);
|
81 |
+
}
|
82 |
+
} else {
|
83 |
+
// Otherwise throw error to upper level
|
84 |
+
throw $e;
|
85 |
+
}
|
86 |
+
return false;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
function uploadAttachment($content, $fileName, $userName, $apiKey) {
|
91 |
+
|
92 |
+
$res = "";
|
93 |
+
$header = "PUT /attachments/upload?username=" . urlencode($userName) . "&api_key=" . urlencode($apiKey) . "&file=" . urlencode($fileName) . " HTTP/1.0\r\n";
|
94 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
95 |
+
$header .= "Content-Length: " . strlen($content) . "\r\n\r\n";
|
96 |
+
$fp = @fsockopen("ssl://api.elasticemail.com", 443, $errno, $errstr, 30);
|
97 |
+
if (!$fp) {
|
98 |
+
return "ERROR. Could not open connection";
|
99 |
+
} else {
|
100 |
+
fputs($fp, $header . $content);
|
101 |
+
while (!feof($fp)) {
|
102 |
+
$res .= fread($fp, 1024);
|
103 |
+
}
|
104 |
+
fclose($fp);
|
105 |
+
}
|
106 |
+
return $res;
|
107 |
+
}
|
108 |
+
|
109 |
+
function mailMerge($csv, $from, $fromName, $subject, $bodyText, $bodyHTML=NULL) {
|
110 |
+
|
111 |
+
$userName = Mage::getStoreConfig('elasticemail/smtp/user');
|
112 |
+
$apiKey = Mage::getStoreConfig('elasticemail/smtp/api');
|
113 |
+
$replyTo = Mage::getStoreConfig('elasticemail/sender/reply');
|
114 |
+
$replytoName = Mage::getStoreConfig('elasticemail/sender/replyname');
|
115 |
+
|
116 |
+
$csvName = 'mailmerge' . rand(100000, 999999) . '.csv';
|
117 |
+
$this->uploadAttachment($csv, $csvName, $userName, $apiKey);
|
118 |
+
|
119 |
+
$res = "";
|
120 |
+
$data = "username=" . urlencode($userName);
|
121 |
+
$data .= "&api_key=" . urlencode($apiKey);
|
122 |
+
$data .= "&from=" . urlencode($from);
|
123 |
+
$data .= "&from_name=" . urlencode($fromName);
|
124 |
+
$data .= "&subject=" . urlencode($subject);
|
125 |
+
$data .= "&data_source=" . urlencode($csvName);
|
126 |
+
if ($bodyHTML)
|
127 |
+
$data .= "&body_html=" . urlencode($bodyHTML);
|
128 |
+
if ($bodyText)
|
129 |
+
$data .= "&body_text=" . urlencode($bodyText);
|
130 |
+
if ($replyTo != '') {
|
131 |
+
$data .= "&reply_to=" . urlencode($replyTo);
|
132 |
+
}
|
133 |
+
if ($replytoName != '') {
|
134 |
+
$data .= "&reply_to_name=" . urlencode($replytoName);
|
135 |
+
}
|
136 |
+
$header = "POST /mailer/send HTTP/1.0\r\n";
|
137 |
+
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
|
138 |
+
$header .= "Content-Length: " . strlen($data) . "\r\n\r\n";
|
139 |
+
$fp = @fsockopen('ssl://api.elasticemail.com', 443, $errno, $errstr, 30);
|
140 |
+
if (!$fp) {
|
141 |
+
return false;
|
142 |
+
} else {
|
143 |
+
fputs($fp, $header . $data);
|
144 |
+
while (!feof($fp)) {
|
145 |
+
$res .= fread($fp, 1024);
|
146 |
+
}
|
147 |
+
fclose($fp);
|
148 |
+
$chars = preg_split('/Content-Length:/', $res, -1);
|
149 |
+
$result = explode("36", $chars[1]);
|
150 |
+
$responsId = $result[1];
|
151 |
+
if ($responsId != '0') {
|
152 |
+
$model = Mage::getModel('elasticemail/transaction');
|
153 |
+
$model->setResponseId($responsId);
|
154 |
+
$model->setType('News Letter');
|
155 |
+
if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
|
156 |
+
$model->setCreatedTime(now())->setUpdateTime(now());
|
157 |
+
} else {
|
158 |
+
$model->setUpdateTime(now());
|
159 |
+
}
|
160 |
+
$model->save();
|
161 |
+
return true;
|
162 |
+
}
|
163 |
+
}
|
164 |
+
return true;
|
165 |
+
}
|
166 |
+
|
167 |
+
}
|
168 |
+
|
app/code/local/Apptha/Elasticemail/Model/Transaction.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: Transaction.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Model_Transaction extends Mage_Core_Model_Abstract {
|
14 |
+
|
15 |
+
public function _construct() {
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('elasticemail/transaction');
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
app/code/local/Apptha/Elasticemail/controllers/Adminhtml/AccountController.php
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: AccountController.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Adminhtml_AccountController extends Mage_Adminhtml_Controller_action {
|
14 |
+
|
15 |
+
protected function _initAction() {
|
16 |
+
$this->loadLayout()
|
17 |
+
->_setActiveMenu('elasticemail/items')
|
18 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Account Manager'), Mage::helper('adminhtml')->__('Account Manager'));
|
19 |
+
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function indexAction() {
|
24 |
+
|
25 |
+
$this->_initAction()
|
26 |
+
->_addContent($this->getLayout()->createBlock('elasticemail/adminhtml_account'))
|
27 |
+
->renderLayout();
|
28 |
+
}
|
29 |
+
|
30 |
+
}
|
app/code/local/Apptha/Elasticemail/controllers/Adminhtml/TransactionController.php
ADDED
@@ -0,0 +1,207 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: TransactionController.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_Adminhtml_TransactionController extends Mage_Adminhtml_Controller_action {
|
14 |
+
|
15 |
+
protected function _initAction() {
|
16 |
+
$this->loadLayout()
|
17 |
+
->_setActiveMenu('elasticemail/items')
|
18 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
19 |
+
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function indexAction() {
|
24 |
+
|
25 |
+
$this->_initAction()
|
26 |
+
->_addContent($this->getLayout()->createBlock('elasticemail/adminhtml_transaction'))
|
27 |
+
->renderLayout();
|
28 |
+
}
|
29 |
+
|
30 |
+
public function editAction() {
|
31 |
+
|
32 |
+
$id = $this->getRequest()->getParam('id');
|
33 |
+
$model = Mage::getModel('elasticemail/transaction')->load($id);
|
34 |
+
|
35 |
+
if ($model->getId() || $id == 0) {
|
36 |
+
|
37 |
+
|
38 |
+
Mage::register('elasticemail_data', $model);
|
39 |
+
|
40 |
+
$this->loadLayout();
|
41 |
+
$this->_setActiveMenu('elasticemail/items');
|
42 |
+
|
43 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item Manager'), Mage::helper('adminhtml')->__('Item Manager'));
|
44 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Item News'), Mage::helper('adminhtml')->__('Item News'));
|
45 |
+
|
46 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
47 |
+
|
48 |
+
$this->_addContent($this->getLayout()->createBlock('elasticemail/adminhtml_transaction_edit'))
|
49 |
+
->_addLeft($this->getLayout()->createBlock('elasticemail/adminhtml_transaction_edit_tabs'));
|
50 |
+
|
51 |
+
$this->renderLayout();
|
52 |
+
} else {
|
53 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('elasticemail')->__('Item does not exist'));
|
54 |
+
$this->_redirect('*/*/');
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
public function deleteAction() {
|
59 |
+
|
60 |
+
if ($this->getRequest()->getParam('id') > 0) {
|
61 |
+
try {
|
62 |
+
$model = Mage::getModel('elasticemail/transaction');
|
63 |
+
|
64 |
+
$model->setId($this->getRequest()->getParam('id'))
|
65 |
+
->delete();
|
66 |
+
|
67 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Item was successfully deleted'));
|
68 |
+
$this->_redirect('*/*/');
|
69 |
+
} catch (Exception $e) {
|
70 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
71 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
72 |
+
}
|
73 |
+
}
|
74 |
+
$this->_redirect('*/*/');
|
75 |
+
}
|
76 |
+
|
77 |
+
//download email list from elastice email account
|
78 |
+
public function statusAction() {
|
79 |
+
$fileName = 'apptha.csv';
|
80 |
+
$id = $this->getRequest()->getParam('id');
|
81 |
+
$model = Mage::getModel('elasticemail/transaction')->load($id);
|
82 |
+
$responseId = trim($model->getResponseId());
|
83 |
+
$ch = curl_init();
|
84 |
+
$url = "https://api.elasticemail.com/mailer/status/$responseId?showdelivered=true&showfailed=true&showpending=true&showopened=true&showclicked=true&showunsubscribed=true&showabusereports=true";
|
85 |
+
$ch = curl_init($url);
|
86 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
87 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
88 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
89 |
+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
90 |
+
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.1.1) Gecko/20090715 Firefox/3.5.1');
|
91 |
+
$xml = curl_exec($ch);
|
92 |
+
$doc = new DOMDocument();
|
93 |
+
$doc->loadXML($xml);
|
94 |
+
|
95 |
+
|
96 |
+
//delivered emails
|
97 |
+
$delivered = $doc->getElementsByTagName("delivered");
|
98 |
+
$deliveredLength = $delivered->length; // this value will also change
|
99 |
+
for ($i = 0; $i < $deliveredLength; $i++) {
|
100 |
+
$deliveredOne .= $delivered->item($i)->nodeValue;
|
101 |
+
}
|
102 |
+
if ($deliveredOne != '' && $deliveredOne != '0') {
|
103 |
+
$content = 'Completed Emails';
|
104 |
+
$content .= $deliveredOne;
|
105 |
+
}
|
106 |
+
//pending emails
|
107 |
+
$pending = $doc->getElementsByTagName("pending");
|
108 |
+
$pendingLength = $pending->length; // this value will also change
|
109 |
+
for ($i = 0; $i < $pendingLength; $i++) {
|
110 |
+
$pendingOne .= $pending->item($i)->nodeValue;
|
111 |
+
}
|
112 |
+
if ($pendingOne != '' && $pendingOne != '0') {
|
113 |
+
$content .= 'Pending Emails';
|
114 |
+
$content .= $pendingOne;
|
115 |
+
}
|
116 |
+
//failed emails
|
117 |
+
$failed = $doc->getElementsByTagName("failed");
|
118 |
+
$failedLength = $failed->length; // this value will also change
|
119 |
+
for ($i = 0; $i < $failedLength; $i++) {
|
120 |
+
$failedOne .= $failed->item($i)->nodeValue;
|
121 |
+
}
|
122 |
+
if ($failedOne != '' && $failedOne != '0') {
|
123 |
+
$content .= 'Failed Emails';
|
124 |
+
$content .= $failedOne;
|
125 |
+
}
|
126 |
+
//opened emails
|
127 |
+
$opened = $doc->getElementsByTagName("opened");
|
128 |
+
$openedLength = $opened->length; // this value will also change
|
129 |
+
for ($i = 0; $i < $openedLength; $i++) {
|
130 |
+
$openedOne .= $opened->item($i)->nodeValue;
|
131 |
+
}
|
132 |
+
if ($openedOne != '' && $openedOne != '0') {
|
133 |
+
$content .= 'Opened Emails';
|
134 |
+
$content .= $openedOne;
|
135 |
+
}
|
136 |
+
//clicked emails
|
137 |
+
$clicked = $doc->getElementsByTagName("clicked");
|
138 |
+
$clickedLength = $clicked->length; // this value will also change
|
139 |
+
for ($i = 0; $i < $clickedLength; $i++) {
|
140 |
+
$clickedOne .= $clicked->item($i)->nodeValue;
|
141 |
+
}
|
142 |
+
if ($clickedOne != '' && $clickedOne != '0') {
|
143 |
+
$content .= 'Clicked Emails';
|
144 |
+
$content .= $clickedOne;
|
145 |
+
}
|
146 |
+
//unsubscribed emails
|
147 |
+
$unsubscribed = $doc->getElementsByTagName("unsubscribed");
|
148 |
+
$unsubscribedLength = $unsubscribed->length; // this value will also change
|
149 |
+
for ($i = 0; $i < $unsubscribedLength; $i++) {
|
150 |
+
$unsubscribedOne .= $unsubscribed->item($i)->nodeValue;
|
151 |
+
}
|
152 |
+
if ($unsubscribedOne != '' && $unsubscribedOne != '0') {
|
153 |
+
$content .= 'Unsubscribed Emails';
|
154 |
+
$content .= $unsubscribedOne;
|
155 |
+
}
|
156 |
+
//abusereports emails
|
157 |
+
$abusereports = $doc->getElementsByTagName("abusereports");
|
158 |
+
$abusereportsLength = $abusereports->length; // this value will also change
|
159 |
+
for ($i = 0; $i < $abusereportsLength; $i++) {
|
160 |
+
$abusereportsOne .= $abusereports->item($i)->nodeValue;
|
161 |
+
}
|
162 |
+
if ($abusereportsOne != '' && $abusereportsOne != '0') {
|
163 |
+
$content .= 'Abusereports Emails';
|
164 |
+
$content .= $abusereportsOne;
|
165 |
+
}
|
166 |
+
|
167 |
+
$this->_sendUploadResponse($fileName, $content);
|
168 |
+
}
|
169 |
+
|
170 |
+
public function massDeleteAction() {
|
171 |
+
$elasticemailIds = $this->getRequest()->getParam('elasticemail');
|
172 |
+
if (!is_array($elasticemailIds)) {
|
173 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
|
174 |
+
} else {
|
175 |
+
try {
|
176 |
+
foreach ($elasticemailIds as $elasticemailId) {
|
177 |
+
$elasticemail = Mage::getModel('elasticemail/transaction')->load($elasticemailId);
|
178 |
+
$elasticemail->delete();
|
179 |
+
}
|
180 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
181 |
+
Mage::helper('adminhtml')->__(
|
182 |
+
'Total of %d record(s) were successfully deleted', count($elasticemailIds)
|
183 |
+
)
|
184 |
+
);
|
185 |
+
} catch (Exception $e) {
|
186 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
187 |
+
}
|
188 |
+
}
|
189 |
+
$this->_redirect('*/*/index');
|
190 |
+
}
|
191 |
+
|
192 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream') {
|
193 |
+
$response = $this->getResponse();
|
194 |
+
$response->setHeader('HTTP/1.1 200 OK', '');
|
195 |
+
$response->setHeader('Pragma', 'public', true);
|
196 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
197 |
+
$response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
|
198 |
+
$response->setHeader('Last-Modified', date('r'));
|
199 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
200 |
+
$response->setHeader('Content-Length', strlen($content));
|
201 |
+
$response->setHeader('Content-type', $contentType);
|
202 |
+
$response->setBody($content);
|
203 |
+
$response->sendResponse();
|
204 |
+
die;
|
205 |
+
}
|
206 |
+
|
207 |
+
}
|
app/code/local/Apptha/Elasticemail/controllers/IndexController.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @name Elastice Email.
|
5 |
+
* @version 1.0: IndexController.php$
|
6 |
+
* @since Magento
|
7 |
+
* @package Apptha
|
8 |
+
* @subpackage Elastice Email
|
9 |
+
* @author vasanth
|
10 |
+
* @copyright Copyright (C) 2011 powered by Apptha
|
11 |
+
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
|
12 |
+
*/
|
13 |
+
class Apptha_Elasticemail_IndexController extends Mage_Core_Controller_Front_Action {
|
14 |
+
|
15 |
+
public function indexAction() {
|
16 |
+
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
app/code/local/Apptha/Elasticemail/etc/adminhtml.xml
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
|
3 |
+
<config>
|
4 |
+
<menu>
|
5 |
+
<elasticemail translate="title" module="elasticemail">
|
6 |
+
<title>Elastic Email</title>
|
7 |
+
<sort_order>71</sort_order>
|
8 |
+
<children>
|
9 |
+
<accountdetail translate="title">
|
10 |
+
<title>Account Dashboard</title>
|
11 |
+
<sort_order>1</sort_order>
|
12 |
+
<action>elasticemail/adminhtml_account</action>
|
13 |
+
</accountdetail>
|
14 |
+
<transactions translate="title">
|
15 |
+
<title>Transactions</title>
|
16 |
+
<sort_order>2</sort_order>
|
17 |
+
<action>elasticemail/adminhtml_transaction</action>
|
18 |
+
</transactions>
|
19 |
+
<config translate="title">
|
20 |
+
<title>Configuration</title>
|
21 |
+
<sort_order>3</sort_order>
|
22 |
+
<action>adminhtml/system_config/edit/section/elasticemail</action>
|
23 |
+
</config>
|
24 |
+
</children>
|
25 |
+
</elasticemail>
|
26 |
+
</menu>
|
27 |
+
|
28 |
+
<acl>
|
29 |
+
<resources>
|
30 |
+
<admin>
|
31 |
+
<children>
|
32 |
+
<system>
|
33 |
+
<children>
|
34 |
+
<config>
|
35 |
+
<children>
|
36 |
+
<elasticemail translate="title" module="elasticemail">
|
37 |
+
<title>Elastic Email</title>
|
38 |
+
</elasticemail>
|
39 |
+
</children>
|
40 |
+
</config>
|
41 |
+
</children>
|
42 |
+
</system>
|
43 |
+
</children>
|
44 |
+
</admin>
|
45 |
+
</resources>
|
46 |
+
</acl>
|
47 |
+
</config>
|
app/code/local/Apptha/Elasticemail/etc/config.xml
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Apptha_Elasticemail>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Apptha_Elasticemail>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<elasticemail>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>Apptha_Elasticemail</module>
|
14 |
+
<frontName>elasticemail</frontName>
|
15 |
+
</args>
|
16 |
+
</elasticemail>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<elasticemail>
|
21 |
+
<file>elasticemail.xml</file>
|
22 |
+
</elasticemail>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
</frontend>
|
26 |
+
<admin>
|
27 |
+
<routers>
|
28 |
+
<elasticemail>
|
29 |
+
<use>admin</use>
|
30 |
+
<args>
|
31 |
+
<module>Apptha_Elasticemail</module>
|
32 |
+
<frontName>elasticemail</frontName>
|
33 |
+
</args>
|
34 |
+
</elasticemail>
|
35 |
+
</routers>
|
36 |
+
</admin>
|
37 |
+
<adminhtml>
|
38 |
+
<layout>
|
39 |
+
<updates>
|
40 |
+
<elasticemail>
|
41 |
+
<file>elasticemail.xml</file>
|
42 |
+
</elasticemail>
|
43 |
+
</updates>
|
44 |
+
</layout>
|
45 |
+
</adminhtml>
|
46 |
+
<global>
|
47 |
+
<models>
|
48 |
+
<elasticemail>
|
49 |
+
<class>Apptha_Elasticemail_Model</class>
|
50 |
+
<resourceModel>elasticemail_mysql4</resourceModel>
|
51 |
+
</elasticemail>
|
52 |
+
<newsletter>
|
53 |
+
<rewrite>
|
54 |
+
<template>Apptha_Elasticemail_Model_Newsletter_Template</template>
|
55 |
+
<queue>Apptha_Elasticemail_Model_Newsletter_Queue</queue>
|
56 |
+
</rewrite>
|
57 |
+
</newsletter>
|
58 |
+
<core>
|
59 |
+
<rewrite>
|
60 |
+
<email>Apptha_Elasticemail_Model_Email</email>
|
61 |
+
<email_template>Apptha_Elasticemail_Model_Email_Template</email_template>
|
62 |
+
</rewrite>
|
63 |
+
</core>
|
64 |
+
|
65 |
+
|
66 |
+
<elasticemail_mysql4>
|
67 |
+
<class>Apptha_Elasticemail_Model_Mysql4</class>
|
68 |
+
<entities>
|
69 |
+
<transaction>
|
70 |
+
<table>elasticemail_transaction</table>
|
71 |
+
</transaction>
|
72 |
+
|
73 |
+
|
74 |
+
</entities>
|
75 |
+
</elasticemail_mysql4>
|
76 |
+
</models>
|
77 |
+
<resources>
|
78 |
+
<elasticemail_setup>
|
79 |
+
<setup>
|
80 |
+
<module>Apptha_Elasticemail</module>
|
81 |
+
</setup>
|
82 |
+
<connection>
|
83 |
+
<use>core_setup</use>
|
84 |
+
</connection>
|
85 |
+
</elasticemail_setup>
|
86 |
+
<elasticemail_write>
|
87 |
+
<connection>
|
88 |
+
<use>core_write</use>
|
89 |
+
</connection>
|
90 |
+
</elasticemail_write>
|
91 |
+
<elasticemail_read>
|
92 |
+
<connection>
|
93 |
+
<use>core_read</use>
|
94 |
+
</connection>
|
95 |
+
</elasticemail_read>
|
96 |
+
</resources>
|
97 |
+
<blocks>
|
98 |
+
<elasticemail>
|
99 |
+
<class>Apptha_Elasticemail_Block</class>
|
100 |
+
</elasticemail>
|
101 |
+
</blocks>
|
102 |
+
<helpers>
|
103 |
+
<elasticemail>
|
104 |
+
<class>Apptha_Elasticemail_Helper</class>
|
105 |
+
</elasticemail>
|
106 |
+
</helpers>
|
107 |
+
</global>
|
108 |
+
</config>
|
app/code/local/Apptha/Elasticemail/etc/system.xml
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<tabs>
|
4 |
+
<elasticemail translate="label" module="elasticemail">
|
5 |
+
<label>Apptha</label>
|
6 |
+
<sort_order>197</sort_order>
|
7 |
+
</elasticemail>
|
8 |
+
</tabs>
|
9 |
+
<sections>
|
10 |
+
<elasticemail translate="label" module="elasticemail">
|
11 |
+
<label>Elastic Email</label>
|
12 |
+
<tab>elasticemail</tab>
|
13 |
+
<frontend_type>text</frontend_type>
|
14 |
+
<sort_order>100</sort_order>
|
15 |
+
<show_in_default>1</show_in_default>
|
16 |
+
<show_in_website>1</show_in_website>
|
17 |
+
<show_in_store>1</show_in_store>
|
18 |
+
<groups>
|
19 |
+
<smtp translate="label">
|
20 |
+
<label>SMTP Configuration</label>
|
21 |
+
<show_in_default>1</show_in_default>
|
22 |
+
<show_in_website>1</show_in_website>
|
23 |
+
<show_in_store>1</show_in_store>
|
24 |
+
<sort_order>6</sort_order>
|
25 |
+
<fields>
|
26 |
+
<server translate="label">
|
27 |
+
<label>SMTP Server</label>
|
28 |
+
<frontend_type>text</frontend_type>
|
29 |
+
<sort_order>3</sort_order>
|
30 |
+
<comment>SMTP Server link</comment>
|
31 |
+
<show_in_default>1</show_in_default>
|
32 |
+
<show_in_website>1</show_in_website>
|
33 |
+
<show_in_store>1</show_in_store>
|
34 |
+
</server>
|
35 |
+
<port translate="label">
|
36 |
+
<label>SMTP Port</label>
|
37 |
+
<frontend_type>text</frontend_type>
|
38 |
+
<sort_order>4</sort_order>
|
39 |
+
<show_in_default>1</show_in_default>
|
40 |
+
<show_in_website>1</show_in_website>
|
41 |
+
<show_in_store>1</show_in_store>
|
42 |
+
</port>
|
43 |
+
<user translate="label">
|
44 |
+
<label>User Name</label>
|
45 |
+
<frontend_type>text</frontend_type>
|
46 |
+
<comment>Elastic Eail Username</comment>
|
47 |
+
<sort_order>5</sort_order>
|
48 |
+
<show_in_default>1</show_in_default>
|
49 |
+
<show_in_website>1</show_in_website>
|
50 |
+
<show_in_store>1</show_in_store>
|
51 |
+
</user>
|
52 |
+
<api translate="label">
|
53 |
+
<label>Api Key</label>
|
54 |
+
<frontend_type>text</frontend_type>
|
55 |
+
<comment>Elastic Email Apikey</comment>
|
56 |
+
<sort_order>6</sort_order>
|
57 |
+
<show_in_default>1</show_in_default>
|
58 |
+
<show_in_website>1</show_in_website>
|
59 |
+
<show_in_store>1</show_in_store>
|
60 |
+
</api>
|
61 |
+
</fields>
|
62 |
+
</smtp>
|
63 |
+
<sender translate="label">
|
64 |
+
<label>Sender Information</label>
|
65 |
+
<show_in_default>1</show_in_default>
|
66 |
+
<show_in_website>1</show_in_website>
|
67 |
+
<show_in_store>1</show_in_store>
|
68 |
+
<sort_order>10</sort_order>
|
69 |
+
<fields>
|
70 |
+
<sender translate="label">
|
71 |
+
<label>Email Sender</label>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<sort_order>1</sort_order>
|
74 |
+
<comment>(ex:you@yourdomain.com)</comment>
|
75 |
+
<show_in_default>1</show_in_default>
|
76 |
+
<show_in_website>1</show_in_website>
|
77 |
+
<show_in_store>1</show_in_store>
|
78 |
+
</sender>
|
79 |
+
<sendername translate="label">
|
80 |
+
<label>Sender Name</label>
|
81 |
+
<frontend_type>text</frontend_type>
|
82 |
+
<sort_order>2</sort_order>
|
83 |
+
<show_in_default>1</show_in_default>
|
84 |
+
<show_in_website>1</show_in_website>
|
85 |
+
<show_in_store>1</show_in_store>
|
86 |
+
</sendername>
|
87 |
+
<reply translate="label">
|
88 |
+
<label>Reply To Email</label>
|
89 |
+
<frontend_type>text</frontend_type>
|
90 |
+
<comment>(ex:you@yourdomain.com)</comment>
|
91 |
+
<sort_order>3</sort_order>
|
92 |
+
<show_in_default>1</show_in_default>
|
93 |
+
<show_in_website>1</show_in_website>
|
94 |
+
<show_in_store>1</show_in_store>
|
95 |
+
</reply>
|
96 |
+
<replyname translate="label">
|
97 |
+
<label>Reply To Name</label>
|
98 |
+
<frontend_type>text</frontend_type>
|
99 |
+
<sort_order>4</sort_order>
|
100 |
+
<show_in_default>1</show_in_default>
|
101 |
+
<show_in_website>1</show_in_website>
|
102 |
+
<show_in_store>1</show_in_store>
|
103 |
+
</replyname>
|
104 |
+
</fields>
|
105 |
+
</sender>
|
106 |
+
</groups>
|
107 |
+
</elasticemail>
|
108 |
+
</sections>
|
109 |
+
</config>
|
app/code/local/Apptha/Elasticemail/sql/elasticemail_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('elasticemail')};
|
10 |
+
CREATE TABLE {$this->getTable('elasticemail_transaction')} (
|
11 |
+
`transaction_id` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
12 |
+
`response_id` varchar(256) NOT NULL,
|
13 |
+
`type` varchar(128) NOT NULL,
|
14 |
+
`created_time` datetime DEFAULT NULL,
|
15 |
+
`update_time` datetime DEFAULT NULL,
|
16 |
+
PRIMARY KEY (`transaction_id`)
|
17 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
18 |
+
|
19 |
+
");
|
20 |
+
|
21 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/elasticemail.xml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<elasticemail_adminhtml_elasticemail_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="elasticemail/adminhtml_elasticemail" name="elasticemail" />
|
6 |
+
</reference>
|
7 |
+
</elasticemail_adminhtml_elasticemail_index>
|
8 |
+
</layout>
|
app/design/adminhtml/default/default/template/elasticemail/account.phtml
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2 |
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
3 |
+
<head>
|
4 |
+
<link rel="stylesheet" href="<?php echo $this->getSkinUrl('elasticemail.css') ?>" type="text/css" />
|
5 |
+
|
6 |
+
</head>
|
7 |
+
<body>
|
8 |
+
<div id="AccountProfile">
|
9 |
+
<table style="width:100%;">
|
10 |
+
<tbody>
|
11 |
+
<tr><td>
|
12 |
+
<h4><?php echo $this->__('SMTP Configuration') ?></h4>
|
13 |
+
<p><?php echo $this->__('Configure your SMTP server options with the following:') ?></p>
|
14 |
+
<ul><li><?php echo $this->__('SMTP Server : ') ?><?php echo Mage::getStoreConfig('elasticemail/smtp/server'); ?></li>
|
15 |
+
<li><?php echo $this->__('SMTP Port : ') ?><?php echo Mage::getStoreConfig('elasticemail/smtp/port'); ?></li>
|
16 |
+
<li><?php echo $this->__('Username : ') ?><?php echo Mage::getStoreConfig('elasticemail/smtp/user'); ?></li>
|
17 |
+
<li><?php echo $this->__('Password : ') ?> <?php echo Mage::getStoreConfig('elasticemail/smtp/api'); ?></li>
|
18 |
+
</ul></td>
|
19 |
+
<td>
|
20 |
+
<h4><?php echo $this->__('REST API Configuration') ?></h4>
|
21 |
+
<p><?php echo $this->__('Use the following for your api credentials:') ?></p>
|
22 |
+
<ul><li><?php echo $this->__('username = ') ?><?php echo Mage::getStoreConfig('elasticemail/smtp/user'); ?></li>
|
23 |
+
<li><?php echo $this->__('api_key = ') ?><?php echo Mage::getStoreConfig('elasticemail/smtp/api'); ?></li>
|
24 |
+
</ul>
|
25 |
+
</td>
|
26 |
+
|
27 |
+
<td>
|
28 |
+
<div id="AccountBalanceInfo">
|
29 |
+
<h4><?php echo $this->__('Credit Balance:') ?> $<?php echo $this->getCredit(); ?></h4>
|
30 |
+
<p><?php echo $this->__('Note: You will be notified by email at ') ?><?php echo Mage::getStoreConfig('elasticemail/smtp/user'); ?><?php echo $this->__('when your account balance reaches $50, $25, $5, $1 and 0.') ?></p>
|
31 |
+
<p><a href="https://elasticemail.com/get-credit" title="Add credit to your Elastic Email account."><?php echo $this->__('Buy Credit')?></a></p>
|
32 |
+
</div>
|
33 |
+
</td>
|
34 |
+
</tr>
|
35 |
+
<tr>
|
36 |
+
<td>
|
37 |
+
<h4><?php echo $this->__('Sender Information') ?></h4>
|
38 |
+
<p><?php echo $this->__('Configure your sender information options with the following:') ?></p>
|
39 |
+
<ul><li><?php echo $this->__('Sender Email : ') ?><?php echo Mage::getStoreConfig('elasticemail/sender/sender'); ?></li>
|
40 |
+
<li><?php echo $this->__('Sender Name : ') ?><?php echo Mage::getStoreConfig('elasticemail/sender/sendername'); ?></li>
|
41 |
+
<li><?php echo $this->__('Reply To Email : ') ?><?php echo Mage::getStoreConfig('elasticemail/sender/reply'); ?></li>
|
42 |
+
<li><?php echo $this->__('Reply To Name : ') ?> <?php echo Mage::getStoreConfig('elasticemail/sender/replyname'); ?></li>
|
43 |
+
</ul>
|
44 |
+
</td>
|
45 |
+
|
46 |
+
</tr>
|
47 |
+
</tbody>
|
48 |
+
</table>
|
49 |
+
</div>
|
50 |
+
</body></html>
|
app/etc/modules/Apptha_Elasticemail.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Apptha_Elasticemail>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Apptha_Elasticemail>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Elastic_Email_Extension</name>
|
4 |
+
<version>1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Elastic Email is a mail relay service. That is, instead of your website sending mail via its own SMTP server, outgoing email is directed through the Elastic Email service and out onto the internet. This module provides plug n' play integration with the Elastic Email service.</summary>
|
10 |
+
<description>Elastic Email is a mail relay service. That is, instead of your website sending mail via its own SMTP server, outgoing email is directed through the Elastic Email service and out onto the internet. This module provides plug n' play integration with the Elastic Email service.</description>
|
11 |
+
<notes>Elastic Email is a mail relay service. That is, instead of your website sending mail via its own SMTP server, outgoing email is directed through the Elastic Email service and out onto the internet. This module provides plug n' play integration with the Elastic Email service.</notes>
|
12 |
+
<authors><author><name>Apptha</name><user>auto-converted</user><email>info@apptha.com</email></author></authors>
|
13 |
+
<date>2011-09-02</date>
|
14 |
+
<time>18:19:32</time>
|
15 |
+
<contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="elasticemail.xml" hash="a64d36e185bda193a08780754e04fa79"/></dir><dir name="template"><dir name="elasticemail"><file name="account.phtml" hash="2c22bcd188c3340338f821b6cd0a4b8d"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><file name="elasticemail.css" hash="b2ffa7a809897e86c2756b8643023f98"/></dir></dir></dir></target><target name="magelocal"><dir name="Apptha"><dir name="Elasticemail"><dir name="Block"><file name="Elasticemail.php" hash="685564e125a6fc4ec237b0de0062514b"/><dir name="Adminhtml"><file name="Account.php" hash="ca70240266a2ed0ce2632157a124f0bb"/><file name="Transaction.php" hash="7ad1dd7d79e9695f4ae56cc16d3f5cba"/><dir name="Account"><file name="Grid.php" hash="af2a8b649f4b6c6cbc736809baf95540"/></dir><dir name="Transaction"><file name="Grid.php" hash="eb7c5add9c6eda370fcdd88ac41f54a2"/><dir name="Renderer"><file name="Status.php" hash="72bd25e189fb32e947c2784b688adc08"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="ae60b6742c71f44492d875d2a9222f56"/><dir name="Adminhtml"><file name="AccountController.php" hash="ad4565a56f36a6f9f84a879311c82301"/><file name="TransactionController.php" hash="0abb492029a0bcacde5579d4613bd6e4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="030cd93ab895711ba63232bc5ca23e1f"/><file name="config.xml" hash="2402cdf3db790770b10fb43dfefd8f14"/><file name="system.xml" hash="75f4429eb0fb3aa2865aca21df05e83b"/></dir><dir name="Helper"><file name="Data.php" hash="f70dfcb1d78707b90c837277ee560203"/></dir><dir name="Model"><file name="Email.php" hash="f9afdebc28a440a1c27234608601c3c4"/><file name="Transaction.php" hash="fc93c7eeac509d2e10da7d59185a9271"/><dir name="Email"><file name="Template.php" hash="7b7e663ce3240a255642f52fd019b8b3"/></dir><dir name="Mysql4"><file name="Transaction.php" hash="d2734f5a3b0e560f04cdf74886c81da4"/><dir name="Transaction"><file name="Collection.php" hash="7db6246aa0fd9f90ee9ab090e1ce5a2d"/></dir></dir><dir name="Newsletter"><file name="Queue.php" hash="8d7d565ba2747775702858dd6bf35607"/><file name="Template.php" hash="f89bc480c73ff5c945af987cbb689b8d"/></dir></dir><dir name="sql"><dir name="elasticemail_setup"><file name="mysql4-install-0.1.0.php" hash="652469c1f3df0e19dbb8e4ee3c1203f5"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Apptha_Elasticemail.xml" hash="e7c5bcd93983a71dd92b0baa0c24c4a0"/></dir></target></contents>
|
16 |
+
<compatible/>
|
17 |
+
<dependencies/>
|
18 |
+
</package>
|
skin/adminhtml/default/default/elasticemail.css
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#AccountProfile a{text-decoration: none;}
|
2 |
+
#AccountProfile #ChangePassword label{float:left;display:block;width:140px;height:22px;line-height:22px;}
|
3 |
+
#AccountProfile td{border: 1px solid #CCC;vertical-align:top;padding:20px;width:400px;}
|
4 |
+
#AccountProfile ul{line-height:22px;}
|
5 |
+
#AccountProfile ul li{display: list-item;list-style-type: disc;margin-left: 25px;}
|
6 |
+
#AccountProfile table{border-spacing:10px;}
|