<?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; spam</title>
	<atom:link href="https://nemops.com/tag/spam/feed/" rel="self" type="application/rss+xml" />
	<link>https://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>https://nemops.com/blocking-spam-emails-in-prestashop/</link>
		<comments>https://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="https://nemops.com/blocking-spam-emails-in-prestashop/">Blocking spam emails in PrestaShop</a> appeared first on <a rel="nofollow" href="https://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="https://nemops.com/blocking-spam-emails-in-prestashop/">Blocking spam emails in PrestaShop</a> appeared first on <a rel="nofollow" href="https://nemops.com">NemoPS</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://nemops.com/blocking-spam-emails-in-prestashop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
