SMTP_Magento - Version 0.1.0

Version Notes

SMTP Magento

Download this release

Release Info

Developer ksvcorporation
Extension SMTP_Magento
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

app/code/community/Mage/Smtp/Helper/Data.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Smtp_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function getTransport()
5
+ {
6
+ $config = array(
7
+ 'port' => Mage::getStoreConfig('smtp/settings/port')
8
+ );
9
+ $config_auth = Mage::getStoreConfig('smtp/settings/auth');
10
+ if ($config_auth != 'none')
11
+ {
12
+ $config['auth'] = $config_auth;
13
+ $config['username'] = Mage::getStoreConfig('smtp/settings/username');
14
+ $config['password'] = Mage::getStoreConfig('smtp/settings/password');
15
+ }
16
+ if (Mage::getStoreConfig('smtp/settings/ssl')!= 0)
17
+ {
18
+ $config['ssl'] = (Mage::getStoreConfig('smtp/settings/ssl') == 1) ? 'tls' :'ssl';
19
+ }
20
+ $transport = new Zend_Mail_Transport_Smtp(Mage::getStoreConfig('smtp/settings/host'), $config);
21
+ return $transport;
22
+ }
23
+ }
24
+
app/code/community/Mage/Smtp/Model/Config/Source/Auth.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Smtp_Model_Config_Source_Auth
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value'=>'none', 'label'=>'None'),
9
+ array('value'=>'plain', 'label'=>'Plain'),
10
+ array('value'=>'login', 'label'=>'Login'),
11
+ array('value'=>'crammd5', 'label'=>'CRAM-MD5'),
12
+ );
13
+ }
14
+ }
app/code/community/Mage/Smtp/Model/Config/Source/Ssl.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Mage_Smtp_Model_Config_Source_Ssl
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array('value'=>0, 'label'=>'No'),
9
+ array('value'=>1, 'label'=>'Yes (tls)'),
10
+ array('value'=>2, 'label'=>'Yes (ssl)')
11
+ );
12
+ }
13
+ }
app/code/community/Mage/Smtp/Model/Email.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Smtp_Model_Email extends Mage_Core_Model_Email
3
+ {
4
+ public function send()
5
+ {
6
+ if (!Mage::getStoreConfig('smtp/settings/enabled'))
7
+ {
8
+ return parent::send();
9
+ }
10
+
11
+ if (Mage::getStoreConfigFlag('system/smtp/disable')) {
12
+ return $this;
13
+ }
14
+
15
+ $mail = new Zend_Mail();
16
+
17
+ if (strtolower($this->getType()) == 'html') {
18
+ $mail->setBodyHtml($this->getBody());
19
+ }
20
+ else {
21
+ $mail->setBodyText($this->getBody());
22
+ }
23
+ $transport = Mage::helper('smtp')->getTransport();
24
+ $mail->setFrom($this->getFromEmail(), $this->getFromName())
25
+ ->addTo($this->getToEmail(), $this->getToName())
26
+ ->setSubject($this->getSubject());
27
+
28
+
29
+ $mail->send($transport);
30
+
31
+ return $this;
32
+ }
33
+ }
app/code/community/Mage/Smtp/Model/Email/Template.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Mage_Smtp_Model_Email_Template extends Mage_Core_Model_Email_Template
3
+ {
4
+ public function send($email, $name=null, array $variables = array())
5
+ {
6
+ if (!Mage::getStoreConfig('smtp/settings/enabled'))
7
+ {
8
+ return parent::send($email, $name, $variables);
9
+ }
10
+ if(!$this->isValidForSend()) {
11
+ return false;
12
+ }
13
+
14
+ if (is_null($name)) {
15
+ $name = substr($email, 0, strpos($email, '@'));
16
+ }
17
+
18
+ $variables['email'] = $email;
19
+ $variables['name'] = $name;
20
+
21
+ $mail = $this->getMail();
22
+ if (is_array($email)) {
23
+ foreach ($email as $emailOne) {
24
+ $mail->addTo($emailOne, $name);
25
+ }
26
+ }
27
+ else {
28
+ $mail->addTo($email, $name);
29
+ }
30
+
31
+ $this->setUseAbsoluteLinks(true);
32
+ $text = $this->getProcessedTemplate($variables, true);
33
+
34
+ if($this->isPlain()) {
35
+ $mail->setBodyText($text);
36
+ } else {
37
+ $mail->setBodyHTML($text);
38
+ }
39
+
40
+ $mail->setSubject($this->getProcessedTemplateSubject($variables));
41
+ $mail->setFrom($this->getSenderEmail(), $this->getSenderName());
42
+
43
+ $transport = Mage::helper('smtp')->getTransport();
44
+ try {
45
+ $mail->send($transport); // Zend_Mail warning..
46
+ $this->_mail = null;
47
+ }
48
+ catch (Exception $e) {
49
+ return false;
50
+ }
51
+ return true;
52
+ }
53
+ }
app/code/community/Mage/Smtp/etc/config.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mage_Smtp>
5
+ <version>0.1.0</version>
6
+ </Mage_Smtp>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <core>
11
+ <rewrite>
12
+ <email_template>Mage_Smtp_Model_Email_Template</email_template>
13
+ <email>Mage_Smtp_Model_Email</email>
14
+ </rewrite>
15
+ </core>
16
+ </models>
17
+ </global>
18
+ <adminhtml>
19
+ <translate>
20
+ <modules>
21
+ <Mage_Smtp>
22
+ <files>
23
+ <default>Mage_Smtp.csv</default>
24
+ </files>
25
+ </Mage_Smtp>
26
+ </modules>
27
+ </translate>
28
+ <acl>
29
+ <resources>
30
+ <admin>
31
+ <children>
32
+ <system>
33
+ <children>
34
+ <config>
35
+ <children>
36
+ <smtp>
37
+ <title>KSV Smtp Module Settings</title>
38
+ </smtp>
39
+ </children>
40
+ </config>
41
+ </children>
42
+ </system>
43
+ </children>
44
+ </admin>
45
+ </resources>
46
+ </acl>
47
+ </adminhtml>
48
+ <default>
49
+ <smtp>
50
+ <settings>
51
+ <enabled>0</enabled>
52
+ <auth>login</auth>
53
+ <username></username>
54
+ <password></password>
55
+ <ssl>0</ssl>
56
+ <host>localhost</host>
57
+ <port>25</port>
58
+ <ssltype></ssltype>
59
+ </settings>
60
+ </smtp>
61
+ </default>
62
+ </config>
app/code/community/Mage/Smtp/etc/system.xml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <tabs>
3
+ <mage_smtp>
4
+ <label>Ksv Extensions</label>
5
+ <sort_order>100</sort_order>
6
+ </mage_smtp>
7
+ </tabs>
8
+ <sections>
9
+ <smtp translate="label" module="smtp">
10
+ <label>SMTP Configuration</label>
11
+ <tab>mage_smtp</tab>
12
+ <frontend_type>text</frontend_type>
13
+ <sort_order>71</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>0</show_in_store>
17
+ <groups>
18
+ <settings translate="label">
19
+ <label>General</label>
20
+ <frontend_type>text</frontend_type>
21
+ <sort_order>1</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>0</show_in_store>
25
+ <fields>
26
+ <enabled translate="label">
27
+ <label>Enable SMTP</label>
28
+ <frontend_type>select</frontend_type>
29
+ <source_model>adminhtml/system_config_source_yesno</source_model>
30
+ <sort_order>1</sort_order>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>0</show_in_store>
34
+ </enabled>
35
+ <auth translate="label">
36
+ <label>Auth Mode</label>
37
+ <frontend_type>select</frontend_type>
38
+ <source_model>smtp/config_source_auth</source_model>
39
+ <sort_order>2</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>0</show_in_store>
43
+ </auth>
44
+ <username translate="label">
45
+ <label>Username</label>
46
+ <frontend_type>text</frontend_type>
47
+ <sort_order>3</sort_order>
48
+ <show_in_default>1</show_in_default>
49
+ <show_in_website>1</show_in_website>
50
+ <show_in_store>0</show_in_store>
51
+ </username>
52
+ <password translate="label">
53
+ <label>Password</label>
54
+ <frontend_type>text</frontend_type>
55
+ <sort_order>4</sort_order>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>0</show_in_store>
59
+ </password>
60
+ <host translate="label">
61
+ <label>Smtp host</label>
62
+ <frontend_type>text</frontend_type>
63
+ <sort_order>5</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ </host>
68
+ <port translate="label">
69
+ <label>Smtp port</label>
70
+ <frontend_type>text</frontend_type>
71
+ <sort_order>6</sort_order>
72
+ <show_in_default>1</show_in_default>
73
+ <show_in_website>1</show_in_website>
74
+ <show_in_store>0</show_in_store>
75
+ </port>
76
+ <ssl translate="label">
77
+ <label>Use SSL</label>
78
+ <frontend_type>select</frontend_type>
79
+ <source_model>smtp/config_source_ssl</source_model>
80
+ <sort_order>7</sort_order>
81
+ <show_in_default>1</show_in_default>
82
+ <show_in_website>1</show_in_website>
83
+ <show_in_store>0</show_in_store>
84
+ </ssl>
85
+ </fields>
86
+ </settings>
87
+ </groups>
88
+ </smtp>
89
+ </sections>
90
+ </config>
app/etc/modules/Mage_Smtp.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Mage_Smtp>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Mage_Smtp>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>SMTP_Magento</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>SMTP Magento Extension support all SMTP servers and also support SSL Authentication.</summary>
10
+ <description>&lt;p&gt;SMTP Magento Extension support all SMTP servers and also support SSL Authentication.&lt;/p&gt;&#xD;
11
+ &lt;p&gt;You can set the SMTP host and port in System &gt; Configuration &gt; KSV Extensions &gt; System &gt; SMTP Configuration.&lt;/p&gt;</description>
12
+ <notes>SMTP Magento</notes>
13
+ <authors><author><name>ksvcorporation</name><user>ksvcorporation</user><email>ksvcorporation@gmail.com</email></author></authors>
14
+ <date>2014-03-01</date>
15
+ <time>18:26:11</time>
16
+ <contents><target name="magecommunity"><dir name="Mage"><dir name="Smtp"><dir name="Helper"><file name="Data.php" hash="b968445f17a7d023aeadacc22a3918f2"/></dir><dir name="Model"><dir name="Config"><dir name="Source"><file name="Auth.php" hash="e939d7fe00118112c301a29568a99154"/><file name="Ssl.php" hash="f1a4ebaf7ed7f917b474ca865419213f"/></dir></dir><dir name="Email"><file name="Template.php" hash="af6c0fc0fe6638c69f7308e774394f64"/></dir><file name="Email.php" hash="456fe985796472f1acb3c9de33d2c6f8"/></dir><dir name="etc"><file name="config.xml" hash="78c2861d039b229108b4befd88e131d3"/><file name="system.xml" hash="867810e0d7e3cf370024a5eac332b4db"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Mage_Smtp.xml" hash="5b7f6a26ca5ff4a89be481f772bb9fcb"/></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
19
+ </package>