Version Notes
Send magento emails by protocol SMTP or save them to a files.
Download this release
Release Info
Developer | Marcin Frymark |
Extension | mail_transport |
Version | 0.1.1.6 |
Comparing to | |
See all releases |
Code changes from version 0.1.1.5 to 0.1.1.6
app/code/community/Alekseon/MailTransport/Model/Email/Template.php
CHANGED
@@ -22,6 +22,24 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
22 |
return false;
|
23 |
}
|
24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
public function getProcessedTemplate(array $variables = array())
|
26 |
{
|
27 |
$processedResult = parent::getProcessedTemplate($variables);
|
@@ -49,7 +67,7 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
49 |
|
50 |
public function getMail($storeId = null)
|
51 |
{
|
52 |
-
if (is_null($this->_mail)) {
|
53 |
$this->_mail = parent::getMail();
|
54 |
$transport = $this->_getTransport($storeId);
|
55 |
if ($transport) {
|
@@ -73,15 +91,26 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
73 |
$transport = $this->_getSmtpTransport($storeId);
|
74 |
break;
|
75 |
case Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_FILE:
|
76 |
-
$transport= $this->
|
77 |
break;
|
|
|
|
|
78 |
}
|
79 |
|
80 |
-
$this->getSentEmailModel()->setTransportType($transportType);
|
81 |
-
|
82 |
return $transport;
|
83 |
}
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
protected function _getSmtpTransport($storeId = null)
|
86 |
{
|
87 |
$host = $this->getMailTransportConfig('smtp_host', $storeId);
|
@@ -98,10 +127,17 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
98 |
}
|
99 |
|
100 |
$transport = new Zend_Mail_Transport_Smtp($host, $config);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
return $transport;
|
102 |
}
|
103 |
|
104 |
-
protected function
|
105 |
{
|
106 |
$path = $this->getMailTransportConfig('file_path', $storeId);
|
107 |
if ($path) {
|
@@ -118,6 +154,21 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
118 |
return $transport;
|
119 |
}
|
120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
121 |
public function send($email, $name = null, array $variables = array())
|
122 |
{
|
123 |
$this->getSentEmailModel()->addSender($this->getSenderEmail(), $this->getSenderName());
|
@@ -132,8 +183,12 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
132 |
$this->getMail($store->getId());
|
133 |
$this->getSentEmailModel()->setStoreId($store->getId());
|
134 |
|
135 |
-
|
136 |
-
|
|
|
|
|
|
|
|
|
137 |
$this->_saveSentEmail($email, $name, $result);
|
138 |
} catch (Exception $e) {
|
139 |
$this->getSentEmailModel()->setComment($e->getMessage());
|
@@ -167,6 +222,7 @@ class Alekseon_MailTransport_Model_Email_Template extends Mage_Core_Model_Email_
|
|
167 |
$name = isset($names[$key]) ? $names[$key] : null;
|
168 |
$this->getSentEmailModel()->addReceipient($email, $name);
|
169 |
}
|
|
|
170 |
$this->getSentEmailModel()->setTemplateType($this->getTemplateType());
|
171 |
$this->getSentEmailModel()->setSentAt(Mage::getSingleton('core/date')->gmtDate());
|
172 |
$this->getSentEmailModel()->setStatus($result);
|
22 |
return false;
|
23 |
}
|
24 |
|
25 |
+
protected function _getReturnPath()
|
26 |
+
{
|
27 |
+
$setReturnPath = Mage::getStoreConfig(Mage_Core_Model_Email_Template::XML_PATH_SENDING_SET_RETURN_PATH);
|
28 |
+
switch ($setReturnPath) {
|
29 |
+
case 1:
|
30 |
+
$returnPathEmail = $this->getSenderEmail();
|
31 |
+
break;
|
32 |
+
case 2:
|
33 |
+
$returnPathEmail = Mage::getStoreConfig(Mage_Core_Model_Email_Template::XML_PATH_SENDING_RETURN_PATH_EMAIL);
|
34 |
+
break;
|
35 |
+
default:
|
36 |
+
$returnPathEmail = null;
|
37 |
+
break;
|
38 |
+
}
|
39 |
+
|
40 |
+
return $returnPathEmail;
|
41 |
+
}
|
42 |
+
|
43 |
public function getProcessedTemplate(array $variables = array())
|
44 |
{
|
45 |
$processedResult = parent::getProcessedTemplate($variables);
|
67 |
|
68 |
public function getMail($storeId = null)
|
69 |
{
|
70 |
+
if (is_null($this->_mail)) {
|
71 |
$this->_mail = parent::getMail();
|
72 |
$transport = $this->_getTransport($storeId);
|
73 |
if ($transport) {
|
91 |
$transport = $this->_getSmtpTransport($storeId);
|
92 |
break;
|
93 |
case Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_FILE:
|
94 |
+
$transport = $this->_getFileTransport($storeId);
|
95 |
break;
|
96 |
+
default:
|
97 |
+
$transport = $this->_getPhpTransport();
|
98 |
}
|
99 |
|
|
|
|
|
100 |
return $transport;
|
101 |
}
|
102 |
|
103 |
+
protected function _getPhpTransport()
|
104 |
+
{
|
105 |
+
$returnPathEmail = $this->_getReturnPath();
|
106 |
+
if ($returnPathEmail) {
|
107 |
+
$trasnport = new Zend_Mail_Transport_Sendmail("-f".$returnPathEmail);
|
108 |
+
} else {
|
109 |
+
$trasnport = new Zend_Mail_Transport_Sendmail();
|
110 |
+
}
|
111 |
+
return $trasnport;
|
112 |
+
}
|
113 |
+
|
114 |
protected function _getSmtpTransport($storeId = null)
|
115 |
{
|
116 |
$host = $this->getMailTransportConfig('smtp_host', $storeId);
|
127 |
}
|
128 |
|
129 |
$transport = new Zend_Mail_Transport_Smtp($host, $config);
|
130 |
+
|
131 |
+
$returnPathEmail = $this->_getReturnPath();
|
132 |
+
|
133 |
+
if ($returnPathEmail) {
|
134 |
+
$this->_mail->setReturnPath($returnPathEmail);
|
135 |
+
}
|
136 |
+
|
137 |
return $transport;
|
138 |
}
|
139 |
|
140 |
+
protected function _getFileTransport($storeId = null)
|
141 |
{
|
142 |
$path = $this->getMailTransportConfig('file_path', $storeId);
|
143 |
if ($path) {
|
154 |
return $transport;
|
155 |
}
|
156 |
|
157 |
+
protected function _setTransportType()
|
158 |
+
{
|
159 |
+
$defaultTransportType = Zend_Mail::getDefaultTransport();
|
160 |
+
if ($defaultTransportType instanceof Zend_Mail_Transport_File) {
|
161 |
+
$transportType = Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_FILE;
|
162 |
+
} else if ($defaultTransportType instanceof Zend_Mail_Transport_Smtp) {
|
163 |
+
$transportType = Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_SMTP;
|
164 |
+
} else {
|
165 |
+
$transportType = Alekseon_MailTransport_Model_System_Config_Source_MailTransportTypes::MAIL_TARNSPORT_TYPE_DEFAULT;
|
166 |
+
}
|
167 |
+
|
168 |
+
$this->getSentEmailModel()->setTransportType($transportType);
|
169 |
+
return $this;
|
170 |
+
}
|
171 |
+
|
172 |
public function send($email, $name = null, array $variables = array())
|
173 |
{
|
174 |
$this->getSentEmailModel()->addSender($this->getSenderEmail(), $this->getSenderName());
|
183 |
$this->getMail($store->getId());
|
184 |
$this->getSentEmailModel()->setStoreId($store->getId());
|
185 |
|
186 |
+
/* set return path to false, to avoid changing transport type by send method in parent class */
|
187 |
+
/* we check this configuration in _getReturnPath method, and we set return path before */
|
188 |
+
Mage::app()->getStore()->setConfig(Mage_Core_Model_Email_Template::XML_PATH_SENDING_SET_RETURN_PATH, false);
|
189 |
+
|
190 |
+
try {
|
191 |
+
$result = parent::send($email, $name, $variables);
|
192 |
$this->_saveSentEmail($email, $name, $result);
|
193 |
} catch (Exception $e) {
|
194 |
$this->getSentEmailModel()->setComment($e->getMessage());
|
222 |
$name = isset($names[$key]) ? $names[$key] : null;
|
223 |
$this->getSentEmailModel()->addReceipient($email, $name);
|
224 |
}
|
225 |
+
$this->_setTransportType();
|
226 |
$this->getSentEmailModel()->setTemplateType($this->getTemplateType());
|
227 |
$this->getSentEmailModel()->setSentAt(Mage::getSingleton('core/date')->gmtDate());
|
228 |
$this->getSentEmailModel()->setStatus($result);
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>mail_transport</name>
|
4 |
-
<version>0.1.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>Send magento emails by protocol SMTP or save them to a files.</description>
|
11 |
<notes>Send magento emails by protocol SMTP or save them to a files.</notes>
|
12 |
<authors><author><name>Marcin Frymark</name><user>Alekseon</user><email>contact@alekseon.com</email></author></authors>
|
13 |
-
<date>2014-07-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Alekseon"><dir name="MailTransport"><dir><dir name="Block"><dir name="Adminhtml"><dir name="SentEmail"><dir name="Grid"><dir name="Renderer"><file name="Receipient.php" hash="88a5e395a965ccae580d84ad0072b08e"/></dir></dir><file name="Grid.php" hash="64407523f244a2bce1a1c72ace24b2ac"/><file name="TopMessage.php" hash="80036003eeab72028e67c8c07f4aa52d"/><dir name="View"><file name="Form.php" hash="4e9aaf1663c7763550b68894eb54a0b0"/><file name="MailBody.php" hash="44abae1440de697501bd9569b1db73b3"/></dir><file name="View.php" hash="e3f941aad29a565e8f7916e237b30c0a"/></dir><file name="SentEmail.php" hash="578c135cc0f4b9bc3ccc01e745e3df2e"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="AlekseonLogo.php" hash="f51973c6b6547da6d3c4662a7fbb6566"/><file name="AlekseonNotification.php" hash="51f024aaf7825e876064ed8c2736c0bb"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f6539af5c617bc24c000d5d22e9ede3f"/></dir><dir name="Model"><dir name="AlekseonAdminNotification"><file name="Feed.php" hash="27c8bdb9455979eddfd9b91b467425aa"/><file name="Observer.php" hash="f44011324cad1c5284d0ea68a6267020"/></dir><dir name="Email"><file name="Template.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>mail_transport</name>
|
4 |
+
<version>0.1.1.6</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>
|
10 |
<description>Send magento emails by protocol SMTP or save them to a files.</description>
|
11 |
<notes>Send magento emails by protocol SMTP or save them to a files.</notes>
|
12 |
<authors><author><name>Marcin Frymark</name><user>Alekseon</user><email>contact@alekseon.com</email></author></authors>
|
13 |
+
<date>2014-07-18</date>
|
14 |
+
<time>08:32:30</time>
|
15 |
+
<contents><target name="magecommunity"><dir name="Alekseon"><dir name="MailTransport"><dir><dir name="Block"><dir name="Adminhtml"><dir name="SentEmail"><dir name="Grid"><dir name="Renderer"><file name="Receipient.php" hash="88a5e395a965ccae580d84ad0072b08e"/></dir></dir><file name="Grid.php" hash="64407523f244a2bce1a1c72ace24b2ac"/><file name="TopMessage.php" hash="80036003eeab72028e67c8c07f4aa52d"/><dir name="View"><file name="Form.php" hash="4e9aaf1663c7763550b68894eb54a0b0"/><file name="MailBody.php" hash="44abae1440de697501bd9569b1db73b3"/></dir><file name="View.php" hash="e3f941aad29a565e8f7916e237b30c0a"/></dir><file name="SentEmail.php" hash="578c135cc0f4b9bc3ccc01e745e3df2e"/><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="AlekseonLogo.php" hash="f51973c6b6547da6d3c4662a7fbb6566"/><file name="AlekseonNotification.php" hash="51f024aaf7825e876064ed8c2736c0bb"/></dir></dir></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="f6539af5c617bc24c000d5d22e9ede3f"/></dir><dir name="Model"><dir name="AlekseonAdminNotification"><file name="Feed.php" hash="27c8bdb9455979eddfd9b91b467425aa"/><file name="Observer.php" hash="f44011324cad1c5284d0ea68a6267020"/></dir><dir name="Email"><file name="Template.php" hash="7ccad73f128c7eb95b0338409834306b"/></dir><file name="Observer.php" hash="cb32eb694fba1e53c2396c0b4398ebf0"/><dir name="Resource"><dir name="SentEmail"><file name="Collection.php" hash="bf1c29041caa2d4614e7894297b55b47"/><dir name="Correspondent"><file name="Collection.php" hash="c4df13aea0717ba228f2b206d71cdc0a"/></dir><file name="Correspondent.php" hash="e4304608fedd99d74e3720ba40ab5811"/></dir><file name="SentEmail.php" hash="3b4302ca7d3c9c9c416dc6d1559847fd"/></dir><dir name="SentEmail"><file name="Correspondent.php" hash="79ce35e0cc043ef088cad17afe87e5b1"/></dir><file name="SentEmail.php" hash="ed67caf05d5f4e804fc24461ff415823"/><dir name="System"><dir name="Config"><dir name="Source"><file name="AllTemplates.php" hash="32458dd1cc2bd26d84f0c7125c1950ab"/><file name="EncryptionProtocols.php" hash="a099d4bece5da8edc2a8534130ad0fac"/><file name="MailTransportTypes.php" hash="0fbf18aad5a6563f59d399d7c2d004c1"/><file name="SmtpAuthModes.php" hash="459adb6fdc8c456693a29190742f03f4"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><dir name="MailTransport"><file name="SentEmailsHistoryController.php" hash="8857976b524cff7451f3fdeeae013932"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="0a84d9392de6dd9ab91fc7cc6b35cc0e"/><file name="config.xml" hash="72f211485e0e60895cc79b624ec4e6f3"/><file name="system.xml" hash="26f65502872705a3f6b61a5046ef25e7"/></dir><dir name="sql"><dir name="alekseon_mailtransport_setup"><file name="mysql4-install-0.1.1.php" hash="e9eab66079a531256d2db8a0895d5d2d"/><file name="mysql4-upgrade-0.1.1-0.1.2.php" hash="3d9654bef73b355ebe8d3b47e72555ff"/><file name="mysql4-upgrade-0.1.2-0.1.3.php" hash="161f973ead0e483088f701e57bc09082"/><file name="mysql4-upgrade-0.1.3-0.1.4.php" hash="aba0dd9636b0fea181d3ec160121de9b"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Alekseon_MailTransport.xml" hash="e99dcf95b0657403cec683729a620450"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="alekseon"><file name="mailTransport.xml" hash="052b7956a3fb7910f5dd29829fc112c7"/></dir></dir><dir name="template"><dir name="alekseon"><dir name="mailTransport"><dir name="sentEmail"><file name="topMessage.phtml" hash="a9440740f61ea7767406108f9011c07c"/><dir name="view"><file name="form.phtml" hash="c3f897163e1636fffee14988d8aae62a"/></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|