{"id":2275,"date":"2020-10-07T00:00:00","date_gmt":"2020-10-07T00:00:00","guid":{"rendered":"https:\/\/www.mailboxvalidator.com\/resources3\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/"},"modified":"2020-10-07T00:00:00","modified_gmt":"2020-10-07T00:00:00","password":"","slug":"how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop","status":"publish","type":"docs","link":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/","title":{"rendered":"How to use MailboxValidator API to validate email in PrestaShop"},"content":{"rendered":"<h2>Overview<\/h2>\n<p><span style=\"font-weight: 400; color: #000000;\">PrestaShop is one of the popular e-commerce platforms used by many merchants around the globe. It comes with many useful features to assist merchants in the daily business operations. However, some built-in features might be just the basic offering merely to support the PrestaShop operation. Take the email validation for example, PrestaShop only validates certain cases. These cases include whether the email field in a form is empty or not, or if the email address entered has a valid format (e.g. xx@xx.xx). What if you want to block those disposable email from account registration. Registration with such an address is a suspicious act due to the anonymity of the email address.<br \/>\n<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #000000;\">To solve this problem, PrestaShop allows you to extend or enhance the built-in feature using a functionality called \u00e2\u20ac\u02dcOverride\u00e2\u20ac\u2122. In this article, we are going to show how to extend the built-in form validation to validate and block invalid email addresses using the MailboxValidator API.<\/span><\/p>\n<p><span style=\"font-weight: 400; color: #000000;\">Note: Before making any modification, please backup your project.<\/span><\/p>\n<div class=\"ast-oembed-container \" style=\"height: 100%;\"><iframe loading=\"lazy\" title=\"Validate an Email Address in PrestaShop\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/GU4AGKMlArw?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/div>\n<h2><span style=\"font-weight: 400;\">Register form<\/span><\/h2>\n<p><span style=\"font-weight: 400; color: #000000;\">To extend in register form:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400; color: #000000;\">Create a new file called CustomerForm.php under your <em>web project root\/override\/classes\/form<\/em>.<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\"><span style=\"font-weight: 400;\">Open the new created file, and save the following code into it:<\/span><\/span>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\n\nclass CustomerForm extends CustomerFormCore\n{\n    public function validate()\n    {\n        $apikey = your_MailboxValidator_API_key;\n        $results = file_get_contents('https:\/\/api.mailboxvalidator.com\/v1\/validation\/single?key=' . $apikey . '&amp;email=' . $this-&gt;getField('email')-&gt;getValue() . '&amp;source=prestashop');\n        $results = json_decode($results);\n        if ($results-&gt;status == 'False') {\n            $this-&gt;getField('email')-&gt;addError($this-&gt;translator-&gt;trans(\n                'Please enter a valid email address.',\n                array(),\n                'Shop.Notifications.Error'\n            ));\n        }\n        parent::validate();\n   }\n}<\/pre>\n<\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">Finally, go to your <em>web project root\/var\/cache\/dev<\/em> if your project is in development, or your <em>web project root\/var\/cache\/prod<\/em> if your project is in production, and delete a file called class_index.php. This is to manually clear the cache to make the changes take effect immediately.<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">Now you can go to the register form, type an invalid email address and see the result. You shall see the error message appear.<\/span><\/li>\n<\/ol>\n<h2><span style=\"font-weight: 400;\">Contact form<\/span><\/h2>\n<p><span style=\"font-weight: 400; color: #000000;\">To extend in contact form:<\/span><\/p>\n<ol>\n<li><span style=\"font-weight: 400; color: #000000;\">Create a new file called contactform.php under your<em> web project root\/override\/modules\/contactform<\/em>.<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\"><span style=\"font-weight: 400;\">Open the new created file, and save the following code into it:<\/span><\/span>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"php\">&lt;?php\n\nClass ContactformOverride extends Contactform\n{\n    public function sendMessage()\n    {\n        if ($from = trim(Tools::getValue('from'))) {\n            $apikey = your_MailboxValidator_API_key;\n            $results = file_get_contents('https:\/\/api.mailboxvalidator.com\/v1\/validation\/single?key=' . $apikey . '&amp;email=' . $from . '&amp;source=prestashop');\n            $results = json_decode($results);\n            if ($results-&gt;status == 'False') {\n                $this-&gt;context-&gt;controller-&gt;errors[] = $this-&gt;trans(\n                    'Please\u00c2\u00a0enter\u00c2\u00a0a\u00c2\u00a0valid\u00c2\u00a0email\u00c2\u00a0address.',\n                    [],\n                    'Shop.Notifications.Error'\n                );\n            }\n            parent::sendMessage();\n        }\n    }\n}<\/pre>\n<\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">Finally, go to your <em>web project root\/var\/cache\/dev<\/em> if your project is in development, or your <em>web project root\/var\/cache\/prod<\/em> if your project is in production, and delete a file called class_index.php. This is to manually clear the cache to make the changes take effect immediately.<\/span><\/li>\n<li><span style=\"font-weight: 400; color: #000000;\">Now you can go to the contact form, type an invalid email address and see the result. You shall see the error message appear.<\/span><\/li>\n<\/ol>\n<hr \/>\n<h2><\/h2>\n<h2 class=\"m-bottom-5\" style=\"text-align: center;\">Get started with MailboxValidator<\/h2>\n<p class=\"m-bottom-5 is-size-20\" style=\"text-align: center;\">Improve your email deliverability and sender reputation in email marketing.<\/p>\n<p class=\"m-bottom-5 is-size-20\" style=\"text-align: center;\">Register today and clean your email lists for <strong>FREE<\/strong>!<\/p>\n<p style=\"text-align: center;\"><a class=\"maxbutton-1 maxbutton maxbutton-sign-up-bulk-trial\" target=\"_blank\" title=\"No Setup Fee. Sign Up Trial Today!\" rel=\"noopener\" href=\"https:\/\/www.mailboxvalidator.com\/plans#mailboxvalidator-freesignup\"><span class='mb-text'>GET STARTED FOR FREE<\/span><\/a><\/p>\n<hr \/>\n","protected":false},"excerpt":{"rendered":"<p>Overview PrestaShop is one of the popular e-commerce platforms used by many merchants around the globe. It comes with many [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"doc_category":[69],"doc_tag":[],"class_list":["post-2275","docs","type-docs","status-publish","hentry","doc_category-technical-articles"],"year_month":"2026-05","word_count":575,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"mbv_editor","author_nicename":"mbv_editor","author_url":"https:\/\/www.mailboxvalidator.com\/resources\/author\/mbv_editor\/"},"doc_category_info":[{"term_name":"Technical Articles","term_url":"https:\/\/www.mailboxvalidator.com\/resources\/article-categories\/technical-articles\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use MailboxValidator API to validate email in PrestaShop -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use MailboxValidator API to validate email in PrestaShop -\" \/>\n<meta property=\"og:description\" content=\"Overview PrestaShop is one of the popular e-commerce platforms used by many merchants around the globe. It comes with many [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/mailboxvalidator\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.mailboxvalidator.com\/resources\/wp-content\/uploads\/2021\/05\/banner-articles-and-tutorials.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@MailBoxV\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/articles\\\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\\\/\",\"url\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/articles\\\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\\\/\",\"name\":\"How to use MailboxValidator API to validate email in PrestaShop -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/#website\"},\"datePublished\":\"2020-10-07T00:00:00+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/articles\\\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/articles\\\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/articles\\\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Knowledge Base\",\"item\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/articles\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to use MailboxValidator API to validate email in PrestaShop\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/#website\",\"url\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/\",\"name\":\"MailboxValidator Articles\",\"description\":\"MailboxValidator Articles\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/#organization\",\"name\":\"MailboxValidator\",\"url\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/cropped-mailboxvalidator-fb-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/wp-content\\\/uploads\\\/2017\\\/11\\\/cropped-mailboxvalidator-fb-logo.png\",\"width\":1199,\"height\":399,\"caption\":\"MailboxValidator\"},\"image\":{\"@id\":\"https:\\\/\\\/www.mailboxvalidator.com\\\/resources\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/mailboxvalidator\",\"https:\\\/\\\/x.com\\\/MailBoxV\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/mailboxvalidator\\\/\",\"https:\\\/\\\/www.pinterest.com\\\/mailboxvalidator\\\/\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCesIP5V7nXRXthaqdjjfCFg\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use MailboxValidator API to validate email in PrestaShop -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/","og_locale":"en_US","og_type":"article","og_title":"How to use MailboxValidator API to validate email in PrestaShop -","og_description":"Overview PrestaShop is one of the popular e-commerce platforms used by many merchants around the globe. It comes with many [&hellip;]","og_url":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/","article_publisher":"https:\/\/www.facebook.com\/mailboxvalidator","og_image":[{"width":1200,"height":600,"url":"https:\/\/www.mailboxvalidator.com\/resources\/wp-content\/uploads\/2021\/05\/banner-articles-and-tutorials.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@MailBoxV","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/","url":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/","name":"How to use MailboxValidator API to validate email in PrestaShop -","isPartOf":{"@id":"https:\/\/www.mailboxvalidator.com\/resources\/#website"},"datePublished":"2020-10-07T00:00:00+00:00","breadcrumb":{"@id":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/how-to-use-mailboxvalidator-api-to-validate-email-in-prestashop\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.mailboxvalidator.com\/resources\/"},{"@type":"ListItem","position":2,"name":"Knowledge Base","item":"https:\/\/www.mailboxvalidator.com\/resources\/articles\/"},{"@type":"ListItem","position":3,"name":"How to use MailboxValidator API to validate email in PrestaShop"}]},{"@type":"WebSite","@id":"https:\/\/www.mailboxvalidator.com\/resources\/#website","url":"https:\/\/www.mailboxvalidator.com\/resources\/","name":"MailboxValidator Articles","description":"MailboxValidator Articles","publisher":{"@id":"https:\/\/www.mailboxvalidator.com\/resources\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.mailboxvalidator.com\/resources\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.mailboxvalidator.com\/resources\/#organization","name":"MailboxValidator","url":"https:\/\/www.mailboxvalidator.com\/resources\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.mailboxvalidator.com\/resources\/#\/schema\/logo\/image\/","url":"https:\/\/www.mailboxvalidator.com\/resources\/wp-content\/uploads\/2017\/11\/cropped-mailboxvalidator-fb-logo.png","contentUrl":"https:\/\/www.mailboxvalidator.com\/resources\/wp-content\/uploads\/2017\/11\/cropped-mailboxvalidator-fb-logo.png","width":1199,"height":399,"caption":"MailboxValidator"},"image":{"@id":"https:\/\/www.mailboxvalidator.com\/resources\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/mailboxvalidator","https:\/\/x.com\/MailBoxV","https:\/\/www.linkedin.com\/company\/mailboxvalidator\/","https:\/\/www.pinterest.com\/mailboxvalidator\/","https:\/\/www.youtube.com\/channel\/UCesIP5V7nXRXthaqdjjfCFg"]}]}},"_links":{"self":[{"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/docs\/2275","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/comments?post=2275"}],"version-history":[{"count":0,"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/docs\/2275\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/media?parent=2275"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/doc_category?post=2275"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/www.mailboxvalidator.com\/resources\/wp-json\/wp\/v2\/doc_tag?post=2275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}