{"id":7355,"date":"2022-09-08T07:29:47","date_gmt":"2022-09-08T01:59:47","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/"},"modified":"2022-09-08T07:29:47","modified_gmt":"2022-09-08T01:59:47","slug":"solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/","title":{"rendered":"[Solved] Verify if email sender has permission to send to a certain address"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-15908963\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"15908963\" data-parentid=\"15903550\" data-score=\"4\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<blockquote>\n<p>but I have no knowledge of PERL at all.<\/p>\n<\/blockquote>\n<p>Then the solution is<\/p>\n<ul>\n<li>to hire someone who does, or<\/li>\n<li>to start learning. See perl tag wiki.<\/li>\n<\/ul>\n<p>(As an aside, the language is called <em>Perl<\/em>, and the interpreter used to run Perl programs is called <em>perl<\/em>. Other capitalizations are a bit frowned upon).<\/p>\n<hr>\n<p>Should you decide to try solving this problem on your own, here are a few pointers:<\/p>\n<p>The problem can be decomposed into subproblems:<\/p>\n<ul>\n<li>\n<p>Parsing the rule file. This is rather easy with the <code>split<\/code> function.<\/p>\n<p>The function takes zero to three arguments: regex, string, limit. If the limit is omitted, the number of resulting fragments is arbitrary. If the string is omitted, then the <code>$_<\/code> special variable is used. If the regex is omitted, it will be treated as if the special value <code>\" \"<\/code> was given: Splits on all whitespace, and removes leading whitespace.<\/p>\n<p>To parse a line, the following will have to be done:<\/p>\n<ul>\n<li>Removing the trailing newline with <code>chomp<\/code>,<\/li>\n<li>Splitting the line on <code>:<\/code> into sender and rule string, with at most two fragments,<\/li>\n<li>Splitting the rule string on <code>,<\/code> into single rules,<\/li>\n<li>Splitting each rule at <code>@<\/code> into user and domain part.<\/li>\n<\/ul>\n<p>The rules can then be saved in a database or a Perl data structure.<\/p>\n<\/li>\n<li>\n<p>Matching rules given a pair of sender and receiver addresses. In case of a database, this could be done with a nice SQL query. In case of a Perl data structure, you would:<\/p>\n<ul>\n<li>retrieve all rules for the sender&#8217;s address<\/li>\n<li>Iterate through all rules: Match the user and domain parts and return true once both match.<\/li>\n<li>Else, return false<\/li>\n<\/ul>\n<p>Matching a rule against an address will first check if the rule part (user\/domain) is a <code>*<\/code>. Else, the parts are tested for equality. Both the user and domain part have to match for the whole rule to match.<\/p>\n<\/li>\n<li>\n<p>Choosing a good Perl data structure: To make our life easy, all email addresses and rules are only handled in their normalized form. This means e.g. lowercase. For each object in the above algorithm, one could define a seperate class. This is probably undesirable. Instead,<\/p>\n<ul>\n<li>Each rule can be represented as a 2-valued array reference<\/li>\n<li>The rule list for a sender could be represented as an array reference of rules.<\/li>\n<li>The association between the sender address and receiver rules can be made through a hash.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr>\n<h2>Code examples<\/h2>\n<h3>Parsing a line<\/h3>\n<p>where the line is given in <code>$_<\/code>, and a hashref <code>$rules_for_sender<\/code> is in scope<\/p>\n<pre><code>chomp;\nmy ($sender, $rules) = map lc, split \/:\/, $_, 2;\nmy @rules = map [split \/@\/], split \/,\/, $rules;\n$rules_for_sender-&gt;{$sender} = \\@rules;\n<\/code><\/pre>\n<h3>Iterating through all rules for a sender<\/h3>\n<pre><code>for my $rule (@{ $rules-&gt;{$sender} } {\n  my ($rule_user, $rule_domain) = @$rule;\n  ...; # do stuff here\n}\n<\/code><\/pre>\n<h3>The rest\u2026<\/h3>\n<p>\u2026is almost trivial if you remember<\/p>\n<ul>\n<li>to normalize correctly,<\/li>\n<li>that <code>use strict; use warnings;<\/code> helps you find many errors, and<\/li>\n<li>that string comparision is done with the <code>eq<\/code> operator.<\/li>\n<\/ul>\n<\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Verify if email sender has permission to send to a certain address <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] but I have no knowledge of PERL at all. Then the solution is to hire someone who does, or to start learning. See perl tag wiki. (As an aside, the language is called Perl, and the interpreter used to run Perl programs is called perl. Other capitalizations are a bit frowned upon). Should you &#8230; <a title=\"[Solved] Verify if email sender has permission to send to a certain address\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\" aria-label=\"More on [Solved] Verify if email sender has permission to send to a certain address\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[361,2050,442,2048,2049],"class_list":["post-7355","post","type-post","status-publish","format-standard","hentry","category-solved","tag-arrays","tag-mail-sender","tag-perl","tag-policy","tag-qmail"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Verify if email sender has permission to send to a certain address - JassWeb<\/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:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Verify if email sender has permission to send to a certain address - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] but I have no knowledge of PERL at all. Then the solution is to hire someone who does, or to start learning. See perl tag wiki. (As an aside, the language is called Perl, and the interpreter used to run Perl programs is called perl. Other capitalizations are a bit frowned upon). Should you ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-08T01:59:47+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Verify if email sender has permission to send to a certain address\",\"datePublished\":\"2022-09-08T01:59:47+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\"},\"wordCount\":467,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"arrays\",\"mail-sender\",\"perl\",\"policy\",\"qmail\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\",\"name\":\"[Solved] Verify if email sender has permission to send to a certain address - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-08T01:59:47+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Verify if email sender has permission to send to a certain address\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Verify if email sender has permission to send to a certain address - JassWeb","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:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Verify if email sender has permission to send to a certain address - JassWeb","og_description":"[ad_1] but I have no knowledge of PERL at all. Then the solution is to hire someone who does, or to start learning. See perl tag wiki. (As an aside, the language is called Perl, and the interpreter used to run Perl programs is called perl. Other capitalizations are a bit frowned upon). Should you ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/","og_site_name":"JassWeb","article_published_time":"2022-09-08T01:59:47+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Verify if email sender has permission to send to a certain address","datePublished":"2022-09-08T01:59:47+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/"},"wordCount":467,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["arrays","mail-sender","perl","policy","qmail"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/","url":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/","name":"[Solved] Verify if email sender has permission to send to a certain address - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-08T01:59:47+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-verify-if-email-sender-has-permission-to-send-to-a-certain-address\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Verify if email sender has permission to send to a certain address"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775193939","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/7355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=7355"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/7355\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=7355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=7355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=7355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}