<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>NemoPS &#187; email</title>
	<atom:link href="http://nemops.com/tag/email/feed/" rel="self" type="application/rss+xml" />
	<link>http://nemops.com</link>
	<description>Prestashop Tutorials, Modules and More!</description>
	<lastBuildDate>Wed, 05 Dec 2018 13:25:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.35</generator>
	<item>
		<title>Blocking spam emails in PrestaShop</title>
		<link>http://nemops.com/blocking-spam-emails-in-prestashop/</link>
		<comments>http://nemops.com/blocking-spam-emails-in-prestashop/#comments</comments>
		<pubDate>Wed, 22 Aug 2018 02:11:43 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Tips n Tricks]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[spam]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=3145</guid>
		<description><![CDATA[<p>As you know PrestaShop has been dreaded by a lot of spam issues recently. In this video we will see how to quickly block spam emails coming from the PrestaShop contact form Watch the screencast Let&#8217;s get started! Create a new php file in the override/controllers/front folder, and name it: ContactController.php and add the following [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/blocking-spam-emails-in-prestashop/">Blocking spam emails in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>As you know PrestaShop has been dreaded by a lot of spam issues recently. In this video we will see how to quickly block spam emails coming from the PrestaShop contact form<br />
<span id="more-3145"></span></p>
<h2>Watch the screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/D3_gvr0Raww" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<p>Let&#8217;s get started! Create a new php file in the <em>override/controllers/front</em> folder, and name it: <strong>ContactController.php</strong> and add the following inside php tags:</p>
<pre class="brush: php; title: ; notranslate">

class ContactController extends ContactControllerCore
{
}

</pre>
<p>We need to latch into the postProcess method, so let&#8217;s extend it:</p>
<pre class="brush: php; title: ; notranslate">
public function postProcess()
{
    if(Tools::isSubmit('submitMessage'))
    {
    }
}
</pre>
<p>We want to save the submitted message to a variable first, and then the email:</p>
<pre class="brush: php; title: ; notranslate">
    	$message = Tools::getValue('message');
        $from = trim(Tools::getValue('from'))
</pre>
<p>Now to keep things tidy we will create two new arrays, one will contain the list of strings to ban from emails, the other the ones to ban from the content:</p>
<pre class="brush: php; title: ; notranslate">

            $banned_in_email = ['.ru', 'qq.com', '.vn'];
            $banned_content = ['email marketing'];
</pre>
<p><strong>Please Note:</strong> make sure you use strings that are related to the spam you are actually getting. I am getting spam from .ru, qq.com and .vn domains, so that&#8217;s what I am blocking. I also get a lot of emails containing &#8220;email marketing&#8221; in the text, and am unlikely to get anything real with that type of content.<br />
Make sure you do not ban real customers!</p>
<p>We want to loop through both and spawn an error if anything is contained in the submitted variables:</p>
<pre class="brush: php; title: ; notranslate">
            foreach ($banned_in_email as $string) {
                if(strstr($from, $string))
                    $this-&gt;errors[] = Tools::displayError('This email address is not allowed');
            }
            foreach ($banned_content as $string) {
                if(strstr($message, $string))
                    $this-&gt;errors[] = Tools::displayError('Invalid content');
            }
</pre>
<p>And that&#8217;s basically it, we just need to call the parent at the very end of the method:</p>
<p>parent::postProcess();</p>
<p>And we are done! Here is the complete override:</p>
<pre class="brush: php; title: ; notranslate">
class ContactController extends ContactControllerCore
{
    public function postProcess()
    {
        if(Tools::isSubmit('submitMessage')) {

            $message = Tools::getValue('message');
            $from = Tools::getValue('from');

            $banned_in_email = ['.ru', 'qq.com', '.vn'];
            $banned_content = ['email marketing'];

            foreach ($banned_in_email as $string) {
                if(strstr($from, $string))
                    $this-&gt;errors[] = Tools::displayError('This email address is not allowed');
            }

            foreach ($banned_content as $string) {
                if(strstr($message, $string))
                    $this-&gt;errors[] = Tools::displayError('Invalid Content');
            }
        }
        parent::postProcess();
    }
}
</pre>
<p>Before you test, make sure you erase cache/class_index.php, so that the new override is loaded in the system.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/blocking-spam-emails-in-prestashop/">Blocking spam emails in PrestaShop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/blocking-spam-emails-in-prestashop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Custom E-Mail Configuration in PrestaShop (GMail)</title>
		<link>http://nemops.com/custom-e-mail-configuration-in-prestashop-gmail/</link>
		<comments>http://nemops.com/custom-e-mail-configuration-in-prestashop-gmail/#comments</comments>
		<pubDate>Thu, 26 May 2016 09:08:26 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2782</guid>
		<description><![CDATA[<p>In this PrestaShop Tutorial, we sill see how to configure E-Mails with custom SMTP settings, specifically using Gmail with PrestaShop Watch the Screencast</p>
<p>The post <a rel="nofollow" href="http://nemops.com/custom-e-mail-configuration-in-prestashop-gmail/">Custom E-Mail Configuration in PrestaShop (GMail)</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this PrestaShop Tutorial, we sill see how to configure E-Mails with custom SMTP settings, specifically using Gmail with PrestaShop<br />
<span id="more-2782"></span></p>
<h2>Watch the Screencast</h2>

	<div class="video-embed">
		<iframe width="640" height="360" src="http://www.youtube.com/embed/iWcf1JciFmY" frameborder="0" allowfullscreen></iframe><p><a href="https://www.youtube.com/user/NemoPostScriptum/videos" rel="nofollow" title="Subscribe Post Scriptum's Youtube Channel">Subscribe Post Scriptum's Youtube Channel</a></p>	</div>
<p>The post <a rel="nofollow" href="http://nemops.com/custom-e-mail-configuration-in-prestashop-gmail/">Custom E-Mail Configuration in PrestaShop (GMail)</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/custom-e-mail-configuration-in-prestashop-gmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get email notifications for new customers registrations</title>
		<link>http://nemops.com/email-notifications-new-customers/</link>
		<comments>http://nemops.com/email-notifications-new-customers/#comments</comments>
		<pubDate>Mon, 05 Jan 2015 11:38:16 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[customers]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[registration]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=2264</guid>
		<description><![CDATA[<p>In this quick tip we will see how to enable email notifications for when a new client registers to our shop. The Plan Since we want to be informed when a new user registers, we need to add our code snippets right where the user itself is notified about it. For this reason, we will [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/email-notifications-new-customers/">Get email notifications for new customers registrations</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>In this quick tip we will see how to enable email notifications for when a new client registers to our shop.</p>
<p><span id="more-2264"></span></p>
<h2>The Plan</h2>
<p>Since we want to be informed when a new user registers, we need to add our code snippets right where the user itself is notified about it. For this reason, we will be extending the <strong>sendConfirmationMail</strong> method of the AuthController.php file, and create a new email template as well.</p>
<div class="separator"></div>
<h2>The AuthController override</h2>
<p>As always it&#8217;s good practice to use overrides instead of modifying core files directly (to preserve changes after updates). Therefore, create a new file called <strong>AuthController.php</strong> inside <em>override/controllers/front</em>. Inside php tags, paste the following override code:</p>
<pre class="brush: php; title: ; notranslate">
Class AuthController extends AuthControllerCore
{

	
}
</pre>
<p>As mentioned above, we need to extend the default <strong>sendConfirmationMail</strong> method, so let&#8217;s grab it from the original controller and paste it inside our override (this is from Prestashop 1.6.0.9):</p>
<pre class="brush: php; title: ; notranslate">
Class AuthController extends AuthControllerCore
{
	protected function sendConfirmationMail(Customer $customer)
	{
		if (!Configuration::get('PS_CUSTOMER_CREATION_EMAIL'))
			return true;

		return Mail::Send(
			$this-&gt;context-&gt;language-&gt;id,
			'account',
			Mail::l('Welcome!'),
			array(
				'{firstname}' =&gt; $customer-&gt;firstname,
				'{lastname}' =&gt; $customer-&gt;lastname,
				'{email}' =&gt; $customer-&gt;email,
				'{passwd}' =&gt; Tools::getValue('passwd')),
			$customer-&gt;email,
			$customer-&gt;firstname.' '.$customer-&gt;lastname
		);
	}
	
}
</pre>
<p>Just in case, let&#8217;s make sure emails still work. Erase the <strong>class_index.php</strong> located in the <em>cache/</em> folder. Then, try registering a new user and make sure you get the confirmation email. If you do, it&#8217;s time to add another rule to inform the admin; right before the return, add:</p>
<pre class="brush: php; title: ; notranslate">
Mail::Send(
			Configuration::get('PS_LANG_DEFAULT'),
			'account_for_admin',
			Mail::l('New client!'),
			array(
				'{firstname}' =&gt; $customer-&gt;firstname,
				'{lastname}' =&gt; $customer-&gt;lastname,
				'{email}' =&gt; $customer-&gt;email
				),
			Configuration::get('PS_SHOP_EMAIL'),
			Configuration::get('PS_SHOP_NAME')
		);
</pre>
<p><strong>Explanation:</strong> we just copied the returned code and adapted it to our needs;  first, instead of using the customer language to grab the email template, we use the shop&#8217;s default one. This way we don&#8217;t need to create multiple/translated templates. Then, we pass in &#8216;account_for_admin&#8217; as email template name; it doesn&#8217;t exist yet so don&#8217;t try running a new registration or it won&#8217;t work. Then, to preserve the user&#8217;s credentials we get rid of the password. Lastly we set the &#8220;to&#8221; parameter to the shop&#8217;s email, and set the receiver to the shop&#8217;s name. That&#8217;s all there is to it. Let&#8217;s now create that template.</p>
<div class="separator"></div>
<h2>Creating a new email template</h2>
<p>Instead of proceeding from scratch, I generally copy an existing html template, to have them all uniform. Let&#8217;s use that user welcome as base. Reach <em>mails/en</em> (or whatever your default language&#8217;s ISO is, you can check it in the back office, localization, languages); <strong>Clone both account.html and account.txt, and then rename them to account_for_admin.html and account_for_admin.txt</strong>. Open up the .txt file, it will look something like:</p>
<pre class="brush: xml; title: ; notranslate">


[{shop_url}] 

Hi {firstname} {lastname},

Thank you for creating a customer account at {shop_name}. 

Here are your login details:

E-MAIL ADDRESS: {email}

PASSWORD: {passwd} 		 

Important Security Tips:

* Always keep your account details safe.

* Never disclose your login details to anyone.

* Change your password regularly.

* Should you suspect someone is using your account illegally, please
notify us immediately.

You can now place orders on our shop: {shop_name}
[{shop_url}] 

{shop_name} [{shop_url}] powered by
PrestaShop(tm) [http://www.prestashop.com/] 


</pre>
<p>Let&#8217;s modify it so to fit our needs:</p>
<pre class="brush: xml; title: ; notranslate">


[{shop_url}] 

Hi!

A new customer just signed up for an account at {shop_name}. 

Here are the details:

E-MAIL ADDRESS: {email}

NAME: {firstname} {lastname}

</pre>
<p>Then, apply the same modifications to the html file (please note I am only copying relevant parts of the template):</p>
<pre class="brush: xml; title: ; notranslate">

&lt;tr&gt;
	&lt;td align=&quot;center&quot; class=&quot;titleblock&quot; style=&quot;padding:7px 0&quot;&gt;
		&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
			&lt;span class=&quot;title&quot; style=&quot;font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px&quot;&gt;Hi {firstname} {lastname},&lt;/span&gt;&lt;br/&gt;
			&lt;span class=&quot;subtitle&quot; style=&quot;font-weight:500;font-size:16px;text-transform:uppercase;line-height:25px&quot;&gt;Thank you for creating a customer account at {shop_name}.&lt;/span&gt;
		&lt;/font&gt;
	&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>To</p>
<pre class="brush: xml; title: ; notranslate">

&lt;tr&gt;
	&lt;td align=&quot;center&quot; class=&quot;titleblock&quot; style=&quot;padding:7px 0&quot;&gt;
		&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
			&lt;span class=&quot;title&quot; style=&quot;font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px&quot;&gt;Hi!&lt;/span&gt;&lt;br/&gt;
			&lt;span class=&quot;subtitle&quot; style=&quot;font-weight:500;font-size:16px;text-transform:uppercase;line-height:25px&quot;&gt;A new customer just signed up for an account at {shop_name}.&lt;/span&gt;
		&lt;/font&gt;
	&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>Then</p>
<pre class="brush: xml; title: ; notranslate">

&lt;tr&gt;
	&lt;td class=&quot;box&quot; style=&quot;border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0&quot;&gt;
		&lt;table class=&quot;table&quot; style=&quot;width:100%&quot;&gt;
			&lt;tr&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td style=&quot;padding:7px 0&quot;&gt;
					&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
						&lt;p data-html-only=&quot;1&quot; style=&quot;border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px&quot;&gt;
							Your {shop_name} login details						&lt;/p&gt;
						&lt;span style=&quot;color:#777&quot;&gt;
							Here are your login details:&lt;br /&gt; 
							&lt;span style=&quot;color:#333&quot;&gt;&lt;strong&gt;E-mail address: &lt;a href=&quot;mailto:{email}&quot; style=&quot;color:#337ff1&quot;&gt;{email}&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
							&lt;span style=&quot;color:#333&quot;&gt;&lt;strong&gt;Password:&lt;/strong&gt;&lt;/span&gt; {passwd}
						&lt;/span&gt;
					&lt;/font&gt;
				&lt;/td&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>To</p>
<pre class="brush: xml; title: ; notranslate">

&lt;tr&gt;
	&lt;td class=&quot;box&quot; style=&quot;border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0&quot;&gt;
		&lt;table class=&quot;table&quot; style=&quot;width:100%&quot;&gt;
			&lt;tr&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td style=&quot;padding:7px 0&quot;&gt;
					&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
						&lt;p data-html-only=&quot;1&quot; style=&quot;border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px&quot;&gt;
							Your {shop_name} login details						&lt;/p&gt;
						&lt;span style=&quot;color:#777&quot;&gt;
							Here are your login details:&lt;br /&gt; 
							&lt;span style=&quot;color:#333&quot;&gt;&lt;strong&gt;E-mail address: &lt;a href=&quot;mailto:{email}&quot; style=&quot;color:#337ff1&quot;&gt;{email}&lt;/a&gt;&lt;/strong&gt;&lt;/span&gt;&lt;br /&gt;
							&lt;span style=&quot;color:#333&quot;&gt;&lt;strong&gt;Password:&lt;/strong&gt;&lt;/span&gt; {passwd}
						&lt;/span&gt;
					&lt;/font&gt;
				&lt;/td&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/td&gt;
&lt;/tr&gt;
</pre>
<p>Lastly, you can get rid of this:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;tr&gt;
	&lt;td class=&quot;space_footer&quot; style=&quot;padding:0!important&quot;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td class=&quot;box&quot; style=&quot;border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0&quot;&gt;
		&lt;table class=&quot;table&quot; style=&quot;width:100%&quot;&gt;
			&lt;tr&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td style=&quot;padding:7px 0&quot;&gt;
					&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
						&lt;p style=&quot;border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px&quot;&gt;Important Security Tips:&lt;/p&gt;
						&lt;ol style=&quot;margin-bottom:0&quot;&gt;
							&lt;li&gt;Always keep your account details safe.&lt;/li&gt;
							&lt;li&gt;Never disclose your login details to anyone.&lt;/li&gt;
							&lt;li&gt;Change your password regularly.&lt;/li&gt;
							&lt;li&gt;Should you suspect someone is using your account illegally, please notify us immediately.&lt;/li&gt;
						&lt;/ol&gt;
					&lt;/font&gt;
				&lt;/td&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td class=&quot;space_footer&quot; style=&quot;padding:0!important&quot;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td class=&quot;linkbelow&quot; style=&quot;padding:7px 0&quot;&gt;
		&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
			&lt;span&gt;You can now place orders on our shop: &lt;a href=&quot;{shop_url}&quot; style=&quot;color:#337ff1&quot;&gt;{shop_name}&lt;/a&gt;&lt;/span&gt;
		&lt;/font&gt;
	&lt;/td&gt;
&lt;/tr&gt;

						&lt;tr&gt;
							&lt;td class=&quot;space_footer&quot; style=&quot;padding:0!important&quot;&gt;&amp;nbsp;&lt;/td&gt;
						&lt;/tr&gt;
						&lt;tr&gt;
							&lt;td class=&quot;footer&quot; style=&quot;border-top:4px solid #333333;padding:7px 0&quot;&gt;
								&lt;span&gt;&lt;a href=&quot;{shop_url}&quot; style=&quot;color:#337ff1&quot;&gt;{shop_name}&lt;/a&gt; powered by &lt;a href=&quot;http://www.prestashop.com/&quot; style=&quot;color:#337ff1&quot;&gt;PrestaShop&amp;trade;&lt;/a&gt;&lt;/span&gt;
							&lt;/td&gt;
						&lt;/tr&gt;
					&lt;/table&gt;
				&lt;/td&gt;
				&lt;td class=&quot;space&quot; style=&quot;width:20px;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;

</pre>
<p>And it&#8217;s done! Time to test the outcome!</p>
<div class="separator"></div>
<h2>Troubleshooting</h2>
<p>When dealing with emails and Prestashop, there is a high chance of failure. Don&#8217;t be discouraged if if doesn&#8217;t work at the first attempt, and check the following:</p>
<ul>
<li>- Send out a test email from advanced parameters -> emails to your mail address</li>
<li>- Make sure it didn&#8217;t end up in the spam folder</li>
<li>- Double-check the new template name, it must be <strong>account_for_admin</strong> everywhere</li>
<li>- Make sure you added the template to the correct iso folder. If unsure, clone it to every of them</li>
</ul>
<p>If you still don&#8217;t receive the email, it&#8217;s worth trying to kill the Mail::Send method in case of failure, by using the following code instead:</p>
<pre class="brush: php; title: ; notranslate">
Mail::Send(
			Configuration::get('PS_LANG_DEFAULT'),
			'account_for_admin',
			Mail::l('New client!'),
			array(
				'{firstname}' =&gt; $customer-&gt;firstname,
				'{lastname}' =&gt; $customer-&gt;lastname,
				'{email}' =&gt; $customer-&gt;email
				),
			Configuration::get('PS_SHOP_EMAIL'),
			Configuration::get('PS_SHOP_NAME'),
			null,null,null,null,_PS_MAIL_DIR_,true
		);
</pre>
<p>The last parameter I passed in is telling the method to die in case of failure. If that happens, you should be given more info about what went wrong.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/email-notifications-new-customers/">Get email notifications for new customers registrations</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/email-notifications-new-customers/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>How to enable email notifications for Product Comments in Prestashop</title>
		<link>http://nemops.com/prestashop-comments-email-notifications/</link>
		<comments>http://nemops.com/prestashop-comments-email-notifications/#comments</comments>
		<pubDate>Mon, 14 Apr 2014 10:08:53 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[comments]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[prestashop 1.6]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1937</guid>
		<description><![CDATA[<p>If you have a solid and active customer base, it is frustrating to go and check the Product Comments module every day just to know if a new review has been posted. Let&#8217;s see how to add email notifications for comments! Compatibility: Prestashop 1.5, Prestashop 1.6 Version used: Prestashop 1.6 Introduction Although I will be [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-comments-email-notifications/">How to enable email notifications for Product Comments in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>If you have a solid and active customer base, it is frustrating to go and check the Product Comments module every day just to know if a new review has been posted. Let&#8217;s see how to add email notifications for comments!</p>
<p><span id="more-1937"></span><br />
<a class="download-files button style1" href="http://nemops.com/wp-content/uploads/2014/04/comments_alerts.zip" title="Download Project Files">Download Project Files</a></p>
<ul>
<li>Compatibility: <strong>Prestashop 1.5</strong>, <strong>Prestashop 1.6</strong></li>
<li>Version used: <strong>Prestashop 1.6</strong></li>
</ul>
<h2>Introduction</h2>
<p>Although I will be using Prestashop 1.6&#8217;s code for this tutorial, you can apply the same process to the Prestashop 1.5 version of the product comments module. Just be aware that you will have to use a 1.5 email template instead of copying the 1.6 one I will use here, to have all your emails uniform, if needed.</p>
<p>There is a small thing to notice: no language variable is passed when a new comment is added via ajax. This means we will create a new email template for the default shop language only, as, for the time being, I have found no reliable way to create a multilanguage-enabled function for this.</p>
<p>We will be amending one file only throughout the tutorial: <strong>default.php</strong>, along with creating two new email templates in the main <em>mails/*language*</em> folder. Let&#8217;s get started!</p>
<div class="separator"></div>
<h2>The default Comments controller</h2>
<p>Prestashop comments&#8217; submission is handled through an ajax call, so that no page refresh is needed when adding a new one. The main php file beneath all the comment submission process is <strong>default.php</strong>, and can be found in <em>modules/productcomments/controllers/front/</em>. Open it up in your favorite code editor, then locate the <strong>ajaxProcessAddComment()</strong> method.</p>
<p>This function is called upon comment submission, and it&#8217;s the place where we need to add our email send-out.</p>
<pre class="brush: php; title: ; notranslate">
	protected function ajaxProcessAddComment()
	{
		$module_instance = new ProductComments();

		$result = true;
		$id_guest = 0;
		$id_customer = $this-&gt;context-&gt;customer-&gt;id;
		if (!$id_customer)
			$id_guest = $this-&gt;context-&gt;cookie-&gt;id_guest;

		$errors = array();
		// Validation
		if (!Validate::isInt(Tools::getValue('id_product')))
			$errors[] = $module_instance-&gt;l('ID product is incorrect', 'default');
		if (!Tools::getValue('title') || !Validate::isGenericName(Tools::getValue('title')))
			$errors[] = $module_instance-&gt;l('Title is incorrect', 'default');
		if (!Tools::getValue('content') || !Validate::isMessage(Tools::getValue('content')))
			$errors[] = $module_instance-&gt;l('Comment is incorrect', 'default');
		if (!$id_customer &amp;&amp; (!Tools::isSubmit('customer_name') || !Tools::getValue('customer_name') || !Validate::isGenericName(Tools::getValue('customer_name'))))
			$errors[] = $module_instance-&gt;l('Customer name is incorrect', 'default');
		if (!$this-&gt;context-&gt;customer-&gt;id &amp;&amp; !Configuration::get('PRODUCT_COMMENTS_ALLOW_GUESTS'))
			$errors[] = $module_instance-&gt;l('You must be logged in order to send a comment', 'default');
		if (!count(Tools::getValue('criterion')))
			$errors[] = $module_instance-&gt;l('You must give a rating', 'default');

		$product = new Product(Tools::getValue('id_product'));
		if (!$product-&gt;id)
			$errors[] = $module_instance-&gt;l('Product not found', 'default');

		if (!count($errors))
		{
			$customer_comment = ProductComment::getByCustomer(Tools::getValue('id_product'), $id_customer, true, $id_guest);
			if (!$customer_comment || ($customer_comment &amp;&amp; (strtotime($customer_comment['date_add']) + (int)Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME')) &lt; time()))
			{

				$comment = new ProductComment();
				$comment-&gt;content = strip_tags(Tools::getValue('content'));
				$comment-&gt;id_product = (int)Tools::getValue('id_product');
				$comment-&gt;id_customer = (int)$id_customer;
				$comment-&gt;id_guest = $id_guest;
				$comment-&gt;customer_name = Tools::getValue('customer_name');
				if (!$comment-&gt;customer_name)
					$comment-&gt;customer_name = pSQL($this-&gt;context-&gt;customer-&gt;firstname.' '.$this-&gt;context-&gt;customer-&gt;lastname);
				$comment-&gt;title = Tools::getValue('title');
				$comment-&gt;grade = 0;
				$comment-&gt;validate = 0;
				$comment-&gt;save();

				$grade_sum = 0;
				foreach(Tools::getValue('criterion') as $id_product_comment_criterion =&gt; $grade)
				{
					$grade_sum += $grade;
					$product_comment_criterion = new ProductCommentCriterion($id_product_comment_criterion);
					if ($product_comment_criterion-&gt;id)
						$product_comment_criterion-&gt;addGrade($comment-&gt;id, $grade);
				}

				if (count(Tools::getValue('criterion')) &gt;= 1)
				{
					$comment-&gt;grade = $grade_sum / count(Tools::getValue('criterion'));
					// Update Grade average of comment
					$comment-&gt;save();
				}
				$result = true;

				Tools::clearCache(Context::getContext()-&gt;smarty, $this-&gt;getTemplatePath('productcomments-reviews.tpl'));
			}
			else
			{
				$result = false;
				$errors[] = $module_instance-&gt;l('You should wait').' '.Configuration::get('PRODUCT_COMMENTS_MINIMAL_TIME').' '.$module_instance-&gt;l('seconds before posting a new comment');
			}
		}
		else
			$result = false;

		die(Tools::jsonEncode(array(
			'result' =&gt; $result,
			'errors' =&gt; $errors
		)));
	}
</pre>
<p>It would be useless to send an email notification if the comment submission process failed; thus, we will insert our code right after that <strong>$result = true;</strong> declaration.</p>
<p>So, right before Tools::clearCache(Context::getContext()->smarty, $this->getTemplatePath(&#8216;productcomments-reviews.tpl&#8217;)); add:</p>
<pre class="brush: php; title: ; notranslate">
				// send out an email! by Nemo

				$product_name = Product::getProductName($comment-&gt;id_product);
				$shop_email = Configuration::get('PS_SHOP_EMAIL');
				$shop_name = Configuration::get('PS_SHOP_NAME');

				Mail::Send(Configuration::get('PS_LANG_DEFAULT'), 'new_comment', Mail::l('New comment added'),
				array(
					'{comment_content}' =&gt; $comment-&gt;content,
					'{product_name}' =&gt; $product_name
				), $shop_email,
					$shop_name, $shop_email);

</pre>
<p><strong>Explanation:</strong> first off, we need some variables. We get the product name, to print out more information in the email, then the shop name and email to be used as arguments of the Mail::Send function. This very same method is really simple:</p>
<p>We pass the default language to it, then the name of the template we need (which doesn&#8217;t exist yet at this stage, but we will be creating it shortly), then the email Title. As template variables, we want ourselves to be aware of the content of the comment, as well as the product concerned. Lastly, we set the shop email as sender, receiver, and the shop name as receiver&#8217;s name.</p>
<p>We are done with this file already. Let&#8217;s create the actual email templates!</p>
<div class="separator"></div>
<h2>Creating the new email templates</h2>
<p>This is the easiest part. Two files are needed in order for email notifications to work in Prestashop: an .html version, and a .txt one. Reach the main <em>mails/</em> folder, and inside it access the subfolder with your default store language&#8217;s ISO code. Then, create a new file called <strong>new_comment.html</strong> and paste the following inside:</p>
<pre class="brush: xml; title: ; notranslate">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd&quot;&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
		&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0&quot; /&gt;
		&lt;title&gt;Message from {shop_name}&lt;/title&gt;
		

		&lt;style&gt;	@media only screen and (max-width: 300px){ 
				body {
					width:218px !important;
					margin:auto !important;
				}
				.table {width:195px !important;margin:auto !important;}
				.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto !important;display: block !important;}		
				span.title{font-size:20px !important;line-height: 23px !important}
				span.subtitle{font-size: 14px !important;line-height: 18px !important;padding-top:10px !important;display:block !important;}		
				td.box p{font-size: 12px !important;font-weight: bold !important;}
				.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
					display: block !important; 
				}
				.table-recap{width: 200px!important;}
				.table-recap tr td, .conf_body td{text-align:center !important;}	
				.address{display: block !important;margin-bottom: 10px !important;}
				.space_address{display: none !important;}	
			}
	@media only screen and (min-width: 301px) and (max-width: 500px) { 
				body {width:308px!important;margin:auto!important;}
				.table {width:285px!important;margin:auto!important;}	
				.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}	
				.table-recap table, .table-recap thead, .table-recap tbody, .table-recap th, .table-recap td, .table-recap tr { 
					display: block !important; 
				}
				.table-recap{width: 293px !important;}
				.table-recap tr td, .conf_body td{text-align:center !important;}
				
			}
	@media only screen and (min-width: 501px) and (max-width: 768px) {
				body {width:478px!important;margin:auto!important;}
				.table {width:450px!important;margin:auto!important;}	
				.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}			
			}
	@media only screen and (max-device-width: 480px) { 
				body {width:308px!important;margin:auto!important;}
				.table {width:285px;margin:auto!important;}	
				.logo, .titleblock, .linkbelow, .box, .footer, .space_footer{width:auto!important;display: block!important;}
				
				.table-recap{width: 285px!important;}
				.table-recap tr td, .conf_body td{text-align:center!important;}	
				.address{display: block !important;margin-bottom: 10px !important;}
				.space_address{display: none !important;}	
			}
&lt;/style&gt;

	&lt;/head&gt;
	&lt;body style=&quot;-webkit-text-size-adjust:none;background-color:#fff;width:650px;font-family:Open-sans, sans-serif;color:#555454;font-size:13px;line-height:18px;margin:auto&quot;&gt;
		&lt;table class=&quot;table table-mail&quot; style=&quot;width:100%;margin-top:10px;-moz-box-shadow:0 0 5px #afafaf;-webkit-box-shadow:0 0 5px #afafaf;-o-box-shadow:0 0 5px #afafaf;box-shadow:0 0 5px #afafaf;filter:progid:DXImageTransform.Microsoft.Shadow(color=#afafaf,Direction=134,Strength=5)&quot;&gt;
			&lt;tr&gt;
				&lt;td class=&quot;space&quot; style=&quot;width:20px;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td align=&quot;center&quot; style=&quot;padding:7px 0&quot;&gt;
					&lt;table class=&quot;table&quot; bgcolor=&quot;#ffffff&quot; style=&quot;width:100%&quot;&gt;
						&lt;tr&gt;
							&lt;td align=&quot;center&quot; class=&quot;logo&quot; style=&quot;border-bottom:4px solid #333333;padding:7px 0&quot;&gt;
								&lt;a title=&quot;{shop_name}&quot; href=&quot;{shop_url}&quot; style=&quot;color:#337ff1&quot;&gt;
									&lt;img src=&quot;{shop_logo}&quot; alt=&quot;{shop_name}&quot; /&gt;
								&lt;/a&gt;
							&lt;/td&gt;
						&lt;/tr&gt;

&lt;tr&gt;
	&lt;td align=&quot;center&quot; class=&quot;titleblock&quot; style=&quot;padding:7px 0&quot;&gt;
		&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
			&lt;span class=&quot;title&quot; style=&quot;font-weight:500;font-size:28px;text-transform:uppercase;line-height:33px&quot;&gt;Hi!&lt;/span&gt;
		&lt;/font&gt;
	&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td class=&quot;space_footer&quot; style=&quot;padding:0!important&quot;&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
	&lt;td class=&quot;box&quot; style=&quot;border:1px solid #D6D4D4;background-color:#f8f8f8;padding:7px 0&quot;&gt;
		&lt;table class=&quot;table&quot; style=&quot;width:100%&quot;&gt;
			&lt;tr&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
				&lt;td style=&quot;padding:7px 0&quot;&gt;
					&lt;font size=&quot;2&quot; face=&quot;Open-sans, sans-serif&quot; color=&quot;#555454&quot;&gt;
						&lt;p data-html-only=&quot;1&quot; style=&quot;border-bottom:1px solid #D6D4D4;margin:3px 0 7px;text-transform:uppercase;font-weight:500;font-size:18px;padding-bottom:10px&quot;&gt;
							You have received a new comment for the product &quot;{product_name}&quot;						&lt;/p&gt;
						&lt;span style=&quot;color:#777&quot;&gt;
							{comment_content}
						&lt;/span&gt;
					&lt;/font&gt;
				&lt;/td&gt;
				&lt;td width=&quot;10&quot; style=&quot;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/td&gt;
&lt;/tr&gt;

						&lt;tr&gt;
							&lt;td class=&quot;space_footer&quot; style=&quot;padding:0!important&quot;&gt;&amp;nbsp;&lt;/td&gt;
						&lt;/tr&gt;
						&lt;tr&gt;
							&lt;td class=&quot;footer&quot; style=&quot;border-top:4px solid #333333;padding:7px 0&quot;&gt;
								&lt;span&gt;&lt;a href=&quot;{shop_url}&quot; style=&quot;color:#337ff1&quot;&gt;{shop_name}&lt;/a&gt; powered by &lt;a href=&quot;http://www.prestashop.com/&quot; style=&quot;color:#337ff1&quot;&gt;PrestaShop&amp;trade;&lt;/a&gt;&lt;/span&gt;
							&lt;/td&gt;
						&lt;/tr&gt;
					&lt;/table&gt;
				&lt;/td&gt;
				&lt;td class=&quot;space&quot; style=&quot;width:20px;padding:7px 0&quot;&gt;&amp;nbsp;&lt;/td&gt;
			&lt;/tr&gt;
		&lt;/table&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Then create another one named <strong>new_comment.txt</strong>, and paste this inside:</p>
<pre class="brush: xml; title: ; notranslate">

[{shop_url}] 

Hi!,

You have received a new comment for the product &quot;{product_name}&quot;

{comment_content}
{shop_name} [{shop_url}] powered by
PrestaShop(tm) [http://www.prestashop.com/] 


</pre>
<p><strong>NOTE:</strong> If you are using Prestashop 1.6 you can simply copy and paste the above inside a .html and .txt file, otherwise, if you are trying to apply it to 1.5, my suggestion is to pick a default email template, such as the log_alert one, and modify it accordingly by adding the new variables.</p>
<p>We are done! Save, and then test the new email notifications out by adding a comment!</p>
<div class="sepparator"></div>
<h2>Final Notes</h2>
<p>If your emails are not being sent out, make sure you test them by going to <strong>Advanced Parameters, E-Mail</strong> in the back office. Double check our email settings and try sending out a test email as well.</p>
<p>If everything works at this state, inspect the ajax call by accessing the network tab in a browser console (F12 on Chrome, for example). The comment ajax call looks like <strong>default?action=add_comment&#038;secure_key=6efb5690f08b14a4d0c050119418fc68&#038;rand=1397469373235</strong>.</p>
<p>The post <a rel="nofollow" href="http://nemops.com/prestashop-comments-email-notifications/">How to enable email notifications for Product Comments in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/prestashop-comments-email-notifications/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Forbid the usage of junk-alias emails in Prestashop</title>
		<link>http://nemops.com/validate-junk-addresses-prestashop/</link>
		<comments>http://nemops.com/validate-junk-addresses-prestashop/#comments</comments>
		<pubDate>Wed, 12 Mar 2014 10:17:55 +0000</pubDate>
		<dc:creator><![CDATA[Nemo]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[prestashop]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://nemops.com/?p=1905</guid>
		<description><![CDATA[<p>If you want your customers to use a valid email address, you might want to forbid the use of expiring aliases. Let&#8217;s create a module to handle this validation! Version used: Prestashop 1.5.6.2 Compatibility: Prestashop 1.5, Prestashop 1.6 Introduction Depending on your market, a certain percentage of your clients might be using junk email aliases [&#8230;]</p>
<p>The post <a rel="nofollow" href="http://nemops.com/validate-junk-addresses-prestashop/">Forbid the usage of junk-alias emails in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></description>
				<content:encoded><![CDATA[<p>If you want your customers to use a valid email address, you might want to forbid the use of expiring aliases. Let&#8217;s create a module to handle this validation!</p>
<p><span id="more-1905"></span></p>
<a class="download-files button style1" href="http://nemops.com/wp-content/uploads/2014/03/emailchecker_tut.zip" title="Download Project Files">Download Project Files</a>
<ul>
<li>Version used: <strong>Prestashop 1.5.6.2</strong></li>
<li>Compatibility: Prestashop 1.5, Prestashop 1.6</li>
</ul>
<h2>Introduction</h2>
<p>Depending on your market, a certain percentage of your clients might be using junk email aliases when registering or checking out as guests on your site. If you strive to keep a solid customer base, and especially if you want to fidelize them, this might become a real issue at a certain point. Therefore, you want to make sure they use at least a valid, non-junk/alias address on your site.</p>
<p>The issue can easily be solved with the use of <strong>action Hooks</strong>. Prestashop handles address validation through the so-called &#8220;AuthController&#8221;, and wisely comes with an action hook right at the beginning of the  method used to process a new account (be it guest or not) creation.</p>
<p>In today&#8217;s tutorial, we will create a small, lightweight module that hooks to <strong>actionBeforeSubmitAccount</strong>, so we can target any keyword we dislike, and prevent its usage within the email address field. Let&#8217;s get to it!</p>
<div class="separator"></div>
<h2>Step 1 &#8211; Creating the Prestashop Module and the back office interface</h2>
<p>In order to make things easier for us, we will create a back office interface that saves all these words in a single database configuration entry. This way, whenever we feel like adding a new &#8220;banner keyword&#8221; for the email address field, we can simply reach out the module&#8217;s configuration page, add it and save.</p>
<p>Let&#8217;s start by adding a new, simple module. Download the project files, grab the <strong>emailchecker</strong> folder that you find inside the &#8216;start_here&#8217; folder, and drop it inside your <em>modules/</em> folder.</p>
<p>Open up <strong>emailchecker.php</strong>, then modify the <strong>install()</strong> method by registering the new hook, as follows:</p>
<pre class="brush: php; title: ; notranslate">
	public function install()
	{
		if (!parent::install() OR			
			!$this-&gt;registerHook('actionBeforeSubmitAccount'))
			return false;
		return true;
	}
</pre>
<p><strong>actionBeforeSubmitAccount</strong> is the name of the hook we want to target.</p>
<p>Then, let&#8217;s create the markup to handle banned keywords from the back office. Inside the <strong>_displayForm()</strong> method, add the following:</p>
<pre class="brush: php; title: ; notranslate">
		$this-&gt;_html .= '
			&lt;form action=&quot;'.$_SERVER['REQUEST_URI'].'&quot; method=&quot;post&quot;&gt;
				&lt;fieldset&gt;&lt;legend&gt;&lt;img src=&quot;'.$this-&gt;_path.'logo.gif&quot; alt=&quot;&quot; title=&quot;&quot; /&gt;'.$this-&gt;l('Settings').'&lt;/legend&gt;
		';

		$this-&gt;_html .='
					&lt;label&gt;'.$this-&gt;l('Banned keywords').'&lt;/label&gt;
					&lt;div class=&quot;margin-form&quot;&gt;
						&lt;input type=&quot;text&quot; name=&quot;bannedkw&quot; value=&quot;'.Configuration::get('PS_EMAIL_BANNED_KEYWORDS').'&quot;&gt;
					&lt;/div&gt;
					
		';

		/* Submit button */
		$this-&gt;_html .='&lt;p class=&quot;center&quot;&gt;&lt;input type=&quot;submit&quot; name=&quot;submitKw&quot; value=&quot;'.$this-&gt;l('Save Settings').'&quot;&quot; class=&quot;button&quot;&gt;&lt;/p&gt;';


		$this-&gt;_html .= '
				&lt;/fieldset&gt;
			&lt;/form&gt;';
</pre>
<p>It&#8217;s a regular, simple form. If you are not used to creating Prestashop Modules, you might want to have a look at <a href="http://doc.prestashop.com/display/PS15/Creating+a+PrestaShop+module" title="how to create a prestashop module" rel="nofollow">how to create a prestashop module </a> in the official Prestashop Documentation.</p>
<p>Briefly: we added a new field to hold the banned keywords. We will add them in the input one by one, separated by comma. Then, we will save them inside the <strong>PS_EMAIL_BANNED_KEYWORDS</strong>, and this very same value will be displayed, if set, each time we access the form.</p>
<p>At this point, let&#8217;s save the entries to the configuration table. Edit the <strong>_postProcess()</strong> method as follows:</p>
<pre class="brush: php; title: ; notranslate">
	private function _postProcess()
	{
		if (Tools::isSubmit('submitKw')) // handles the basic config update
		{
			Configuration::updateValue('PS_EMAIL_BANNED_KEYWORDS', Tools::getValue('bannedkw'));
			$this-&gt;_html .= $this-&gt;displayConfirmation($this-&gt;l('Keywords updated'));
		}
	}

</pre>
<p>We don&#8217;t really need validation, but feel free to add it if you want to make sure data is entered correctly here (words separated by commas, so Regular Expressions will come in handy).</p>
<p>As a last thing, if you want to make sure no trace is left into the database upon the module&#8217;s removal, erase the configuration entry by editing the uninstall method:</p>
<pre class="brush: php; title: ; notranslate">
public function uninstall()
	{
		if (!parent::uninstall() OR !Configuration::deleteByName('PS_EMAIL_BANNED_KEYWORDS'))
			return false;
		return true;
	}
</pre>
<p>We are done with the back office! Time to install the module. Reach out the modules panel in the back office, look for <strong>emailchecker</strong> and install it. Test the configuration page and make sure you can save keywords properly. Once this is settled, move to the next step!</p>
<div class="separator"></div>
<h2>Validating the email address</h2>
<p>It&#8217;s time to create the hook method that will handle email validation. Inside our module&#8217;s php file, create a new method named <strong>hookActionBeforeSubmitAccount</strong>:</p>
<pre class="brush: php; title: ; notranslate">
	public function hookActionBeforeSubmitAccount($params)
	{
	}
</pre>
<p>Let&#8217;s first grab our keywords:</p>
<pre class="brush: php; title: ; notranslate">
	public function hookActionBeforeSubmitAccount($params)
	{
		
		$banned_keywords = Configuration::get('PS_EMAIL_BANNED_KEYWORDS');
		if(!$banned_keywords)
			return;

	}

</pre>
<p>If nothing is found for that configuration entry, return, as there is nothing to do. Otherwise, explode the keywords string using the comma separator, and iterate through them using a foreach:</p>
<pre class="brush: php; title: ; notranslate">

	public function hookActionBeforeSubmitAccount($params)
	{
		
		$banned_keywords = Configuration::get('PS_EMAIL_BANNED_KEYWORDS');
		if(!$banned_keywords)
			return;
		// explode keywords by comma
		$kw = explode(',', $banned_keywords);
		foreach ($kw as $k) {
			
		}

		return;
	}

</pre>
<p>Finally, let&#8217;s check the presence of our banned keyword inside the email address. There are several methods to do this. The easiest one is using the <strong>strstr</strong> function of PHP. Of course, you might as well use regular expressions if you feel more comfortable with it:</p>
<pre class="brush: php; title: ; notranslate">

	public function hookActionBeforeSubmitAccount($params)
	{
		
		$banned_keywords = Configuration::get('PS_EMAIL_BANNED_KEYWORDS');
		if(!$banned_keywords)
			return;
		// explode keywords by comma
		$kw = explode(',', $banned_keywords);
		foreach ($kw as $k) {
			if (strstr(strtolower(Tools::getValue('email')), strtolower($k))) {
				$this-&gt;context-&gt;controller-&gt;errors[] = Tools::displayError('Invalid email address');
			}
		}

		return;
	}

</pre>
<p>We are telling the script: if the keyword is found inside the email address (if it&#8217;s a substring of it, grabbed using the helper getValue, which retrieves $_POST and $_GET data) add and error to the current controller. Since the current controller is <strong>authController</strong>, the information validation will not proceed, and nothing will be added to the database. This happens because Prestashop checks the size of the <strong>errors</strong> array right before adding data to the store.</p>
<p>Save and test everything out. If it works properly, you should see the message popping out as soon as you try to register using an address containing the banner keyword. This will work for both the standalone account creation, registered client checkout, and guest checkout (both 5-steps and one page).</p>
<p><a href="http://nemops.com/wp-content/uploads/2014/03/email_checker.png"><img src="http://nemops.com/wp-content/uploads/2014/03/email_checker-680x472.png" alt="Forbid junk-alias email usage in Prestashop" width="680" height="472" class="aligncenter size-large wp-image-1904" /></a></p>
<div class="separator"></div>
<h2>Conclusion</h2>
<p>Validating the email address is a very limited usage of the ActionBeforeSubmitAccounthook. You can validate all data sent via $_POST using the account creation form with it. Here is the complete array, take from Prestashop 1.5.6.2:</p>
<pre>
'id_gender' => string '1' (length=1)
  'customer_firstname' => string 'Fabio' (length=6)
  'customer_lastname' => string 'Porta' (length=6)
  'email' => string 'something@mailexpire.com' (length=23)
  'passwd' => string 'mypassw' (length=7)
  'days' => string '' (length=0)
  'months' => string '' (length=0)
  'years' => string '' (length=0)
  'referralprogram' => string '' (length=0)
  'email_create' => string '1' (length=1)
  'is_new_customer' => string '1' (length=1)
  'back' => string 'my-account' (length=10)
  'submitAccount' => string 'Register' (length=8)
</pre>
<p>The post <a rel="nofollow" href="http://nemops.com/validate-junk-addresses-prestashop/">Forbid the usage of junk-alias emails in Prestashop</a> appeared first on <a rel="nofollow" href="http://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://nemops.com/validate-junk-addresses-prestashop/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
