1667596560
NAME
Mail::DMARC - Perl implementation of DMARC
VERSION
version 1.20211209
SYNOPSIS
DMARC: Domain-based Message Authentication, Reporting and Conformance
my $dmarc = Mail::DMARC::PurePerl->new(
... # see the documentation for the "new" method for required args
);
my $result = $dmarc->validate();
if ( $result->result eq 'pass' ) {
...continue normal processing...
return;
};
# any result that did not pass is a fail. Now for disposition
if ( $result->evalated->disposition eq 'reject' ) {
...treat the sender to a 550 ...
};
if ( $result->evalated->disposition eq 'quarantine' ) {
...assign a bunch of spam points...
};
if ( $result->evalated->disposition eq 'none' ) {
...continue normal processing...
};
DESCRIPTION
This module is a suite of tools for implementing DMARC. It adheres to the 2013 DMARC draft, intending to implement every MUST and every SHOULD.
This module can be used by...
When a message arrives via SMTP, the MTA or filtering application can pass in a small amount of metadata about the connection (envelope details, SPF and DKIM results) to Mail::DMARC. When the validate method is called, Mail::DMARC will determine if:
a. the header_from domain exists
b. the header_from domain publishes a DMARC policy
c. if a policy is published...
d. does the message conform to the published policy?
e. did the policy request reporting? If so, save details.
The validation results are returned as a Mail::DMARC::Result object. If the author domain requested a report, it was saved to the Report Store. The Store class includes a SQL implementation that is tested with SQLite, MySQL and PostgreSQL.
There is more information available in the $result object. See Mail::DMARC::Result for complete details.
Reports are viewed with the dmarc_view_reports program or with a web browser and the dmarc_httpd program.
Aggregate reports are sent to their requestors with the dmarc_send_reports program.
For aggregate reports that you have been sent, the dmarc_receive program will parse the email messages (from IMAP, Mbox, or files) and save the report results into the Report Store.
The report store can use the same database to store reports you have received as well as reports you will send. There are several ways to identify the difference, including:
CLASSES
Mail::DMARC - the perl interface for DMARC
Mail::DMARC::Policy - a DMARC policy
Mail::DMARC::PurePerl - Pure Perl implementation of DMARC
Mail::DMARC::Result - the results of applying policy
Mail::DMARC::Report - Reporting: the R in DMARC
Mail::DMARC::Report::Send - send reports via SMTP & HTTP
Mail::DMARC::Report::Receive - receive and store reports from email, HTTP
Mail::DMARC::Report::Store - a persistent data store for aggregate reports
Mail::DMARC::Report::View - CLI and CGI methods for viewing reports
Mail::DMARC::libopendmarc - an XS implementation using libopendmarc
METHODS
Create a DMARC object.
my $dmarc = Mail::DMARC::PurePerl->new;
Populate it.
$dmarc->source_ip('192.0.1.1');
$dmarc->envelope_to('recipient.example.com');
$dmarc->envelope_from('sender.example.com');
$dmarc->header_from('sender.example.com');
$dmarc->dkim( $dkim_verifier );
$dmarc->spf([
{ domain => 'example.com',
scope => 'mfrom',
result => 'pass',
},
{
scope => 'helo',
domain => 'mta.example.com',
result => 'fail',
},
]);
Run the request:
my $result = $dmarc->validate();
Alternatively, pass in all the required parameters in one shot:
my $dmarc = Mail::DMARC::PurePerl->new(
source_ip => '192.0.1.1',
envelope_to => 'example.com',
envelope_from => 'cars4you.info',
header_from => 'yahoo.com',
dkim => $dkim_results, # same format
spf => $spf_results, # as previous example
);
my $result = $dmarc->validate();
The remote IP that attempted sending the message. DMARC only uses this data for reporting to domains that request DMARC reports.
The domain portion of the RFC5321.RcptTo, (aka, the envelope recipient), and the bold portion in the following example:
RCPT TO:<user@example.com>
The domain portion of the RFC5321.MailFrom, (aka, the envelope sender). That is the the bold portion in the following example:
MAIL FROM:<user@example.com>
The domain portion of the RFC5322.From, aka, the From message header.
From: Ultimate Vacation <sweepstakes@example.com>
You can instead pass in the entire From: header with header_from_raw.
Retrieve the header_from domain by parsing it from a raw From field/header. The domain portion is extracted by get_dom_from_header, which is fast, generally effective, but also rather crude. It has limits, so read the description.
If Mail::DKIM::Verifier was used to validate the message, just pass in the Mail::DKIM::Verifier object that processed the message:
$dmarc->dkim( $dkim_verifier );
Otherwise, pass in an array reference. Each member of the DKIM array results represents a DKIM signature in the message and consists of the 4 keys shown in this example:
$dmarc->dkim( [
{
domain => 'example.com',
selector => 'apr2013',
result => 'fail',
human_result=> 'fail (body has been altered)',
},
{
# 2nd signature, if present
},
] );
The dkim results can also be build iteratively by passing in key value pairs or hash references for each signature in the message:
$dmarc->dkim( domain => 'sig1.com', result => 'fail' );
$dmarc->dkim( domain => 'sig2.com', result => 'pass' );
$dmarc->dkim( { domain => 'example.com', result => 'neutral' } );
Each hash or hashref is appended to the dkim array.
Finally, you can pass a coderef which won't be called until the dkim method is used to read the dkim results. It must return an array reference as described above.
The dkim result is an array reference.
The d= parameter in the DKIM signature
The s= parameter in the DKIM signature
The validation results of this signature. One of: none, pass, fail, policy, neutral, temperror, or permerror
Additional information about the DKIM result. This is comparable to Mail::DKIM::Verifier->result_detail.
The spf method works exactly the same as dkim. It accepts named arguments, a hashref, an arrayref, or a coderef:
$dmarc->spf(
domain => 'example.com',
scope => 'mfrom',
result => 'pass',
);
The SPF domain and result are required for DMARC validation and the scope is used for reporting.
The SPF checked domain
The scope of the checked domain: mfrom, helo
The SPF result code: none, neutral, pass, fail, softfail, temperror, or permerror.
DESIGN & GOALS
The DMARC spec is lengthy and evolving, making correctness a moving target. In cases where correctness is ambiguous, options are generally provided.
Providing an implementation of DMARC that SMTP utilities can utilize will aid DMARC adoption.
The list of dependencies appears long because of reporting. If this module is used without reporting, the number of dependencies not included with perl is about 5. See the [Prereq] versus [Prereq / Recommends] sections in dist.ini.
Since DMARC is evolving, this implementation aims to be straight forward and easy to alter and extend. The programming style is primarily OO, which carries a small performance penalty but dividends in maintainability.
When multiple options are available, such as when sending reports via SMTP or HTTP, calls should be made to the parent Send class to broker the request. When storing reports, calls are made to the Store class which dispatches to the SQL class. The idea is that if someone desired a data store other than those provided by perl's DBI class, they could easily implement their own. If you do, please fork it on GitHub and share.
If you deploy this in an environment where performance is insufficient, please profile the app and submit a report and preferably, patches.
SEE ALSO
2015-03 RFC 7489
DMARC Best Current Practices
HISTORY
The daddy of this perl module was a DMARC module for the qpsmtpd MTA.
AUTHORS
CONTRIBUTORS
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by Matt Simerson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Author: msimerson
Source Code: https://github.com/msimerson/mail-dmarc
License: View license
1667596560
NAME
Mail::DMARC - Perl implementation of DMARC
VERSION
version 1.20211209
SYNOPSIS
DMARC: Domain-based Message Authentication, Reporting and Conformance
my $dmarc = Mail::DMARC::PurePerl->new(
... # see the documentation for the "new" method for required args
);
my $result = $dmarc->validate();
if ( $result->result eq 'pass' ) {
...continue normal processing...
return;
};
# any result that did not pass is a fail. Now for disposition
if ( $result->evalated->disposition eq 'reject' ) {
...treat the sender to a 550 ...
};
if ( $result->evalated->disposition eq 'quarantine' ) {
...assign a bunch of spam points...
};
if ( $result->evalated->disposition eq 'none' ) {
...continue normal processing...
};
DESCRIPTION
This module is a suite of tools for implementing DMARC. It adheres to the 2013 DMARC draft, intending to implement every MUST and every SHOULD.
This module can be used by...
When a message arrives via SMTP, the MTA or filtering application can pass in a small amount of metadata about the connection (envelope details, SPF and DKIM results) to Mail::DMARC. When the validate method is called, Mail::DMARC will determine if:
a. the header_from domain exists
b. the header_from domain publishes a DMARC policy
c. if a policy is published...
d. does the message conform to the published policy?
e. did the policy request reporting? If so, save details.
The validation results are returned as a Mail::DMARC::Result object. If the author domain requested a report, it was saved to the Report Store. The Store class includes a SQL implementation that is tested with SQLite, MySQL and PostgreSQL.
There is more information available in the $result object. See Mail::DMARC::Result for complete details.
Reports are viewed with the dmarc_view_reports program or with a web browser and the dmarc_httpd program.
Aggregate reports are sent to their requestors with the dmarc_send_reports program.
For aggregate reports that you have been sent, the dmarc_receive program will parse the email messages (from IMAP, Mbox, or files) and save the report results into the Report Store.
The report store can use the same database to store reports you have received as well as reports you will send. There are several ways to identify the difference, including:
CLASSES
Mail::DMARC - the perl interface for DMARC
Mail::DMARC::Policy - a DMARC policy
Mail::DMARC::PurePerl - Pure Perl implementation of DMARC
Mail::DMARC::Result - the results of applying policy
Mail::DMARC::Report - Reporting: the R in DMARC
Mail::DMARC::Report::Send - send reports via SMTP & HTTP
Mail::DMARC::Report::Receive - receive and store reports from email, HTTP
Mail::DMARC::Report::Store - a persistent data store for aggregate reports
Mail::DMARC::Report::View - CLI and CGI methods for viewing reports
Mail::DMARC::libopendmarc - an XS implementation using libopendmarc
METHODS
Create a DMARC object.
my $dmarc = Mail::DMARC::PurePerl->new;
Populate it.
$dmarc->source_ip('192.0.1.1');
$dmarc->envelope_to('recipient.example.com');
$dmarc->envelope_from('sender.example.com');
$dmarc->header_from('sender.example.com');
$dmarc->dkim( $dkim_verifier );
$dmarc->spf([
{ domain => 'example.com',
scope => 'mfrom',
result => 'pass',
},
{
scope => 'helo',
domain => 'mta.example.com',
result => 'fail',
},
]);
Run the request:
my $result = $dmarc->validate();
Alternatively, pass in all the required parameters in one shot:
my $dmarc = Mail::DMARC::PurePerl->new(
source_ip => '192.0.1.1',
envelope_to => 'example.com',
envelope_from => 'cars4you.info',
header_from => 'yahoo.com',
dkim => $dkim_results, # same format
spf => $spf_results, # as previous example
);
my $result = $dmarc->validate();
The remote IP that attempted sending the message. DMARC only uses this data for reporting to domains that request DMARC reports.
The domain portion of the RFC5321.RcptTo, (aka, the envelope recipient), and the bold portion in the following example:
RCPT TO:<user@example.com>
The domain portion of the RFC5321.MailFrom, (aka, the envelope sender). That is the the bold portion in the following example:
MAIL FROM:<user@example.com>
The domain portion of the RFC5322.From, aka, the From message header.
From: Ultimate Vacation <sweepstakes@example.com>
You can instead pass in the entire From: header with header_from_raw.
Retrieve the header_from domain by parsing it from a raw From field/header. The domain portion is extracted by get_dom_from_header, which is fast, generally effective, but also rather crude. It has limits, so read the description.
If Mail::DKIM::Verifier was used to validate the message, just pass in the Mail::DKIM::Verifier object that processed the message:
$dmarc->dkim( $dkim_verifier );
Otherwise, pass in an array reference. Each member of the DKIM array results represents a DKIM signature in the message and consists of the 4 keys shown in this example:
$dmarc->dkim( [
{
domain => 'example.com',
selector => 'apr2013',
result => 'fail',
human_result=> 'fail (body has been altered)',
},
{
# 2nd signature, if present
},
] );
The dkim results can also be build iteratively by passing in key value pairs or hash references for each signature in the message:
$dmarc->dkim( domain => 'sig1.com', result => 'fail' );
$dmarc->dkim( domain => 'sig2.com', result => 'pass' );
$dmarc->dkim( { domain => 'example.com', result => 'neutral' } );
Each hash or hashref is appended to the dkim array.
Finally, you can pass a coderef which won't be called until the dkim method is used to read the dkim results. It must return an array reference as described above.
The dkim result is an array reference.
The d= parameter in the DKIM signature
The s= parameter in the DKIM signature
The validation results of this signature. One of: none, pass, fail, policy, neutral, temperror, or permerror
Additional information about the DKIM result. This is comparable to Mail::DKIM::Verifier->result_detail.
The spf method works exactly the same as dkim. It accepts named arguments, a hashref, an arrayref, or a coderef:
$dmarc->spf(
domain => 'example.com',
scope => 'mfrom',
result => 'pass',
);
The SPF domain and result are required for DMARC validation and the scope is used for reporting.
The SPF checked domain
The scope of the checked domain: mfrom, helo
The SPF result code: none, neutral, pass, fail, softfail, temperror, or permerror.
DESIGN & GOALS
The DMARC spec is lengthy and evolving, making correctness a moving target. In cases where correctness is ambiguous, options are generally provided.
Providing an implementation of DMARC that SMTP utilities can utilize will aid DMARC adoption.
The list of dependencies appears long because of reporting. If this module is used without reporting, the number of dependencies not included with perl is about 5. See the [Prereq] versus [Prereq / Recommends] sections in dist.ini.
Since DMARC is evolving, this implementation aims to be straight forward and easy to alter and extend. The programming style is primarily OO, which carries a small performance penalty but dividends in maintainability.
When multiple options are available, such as when sending reports via SMTP or HTTP, calls should be made to the parent Send class to broker the request. When storing reports, calls are made to the Store class which dispatches to the SQL class. The idea is that if someone desired a data store other than those provided by perl's DBI class, they could easily implement their own. If you do, please fork it on GitHub and share.
If you deploy this in an environment where performance is insufficient, please profile the app and submit a report and preferably, patches.
SEE ALSO
2015-03 RFC 7489
DMARC Best Current Practices
HISTORY
The daddy of this perl module was a DMARC module for the qpsmtpd MTA.
AUTHORS
CONTRIBUTORS
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by Matt Simerson.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Author: msimerson
Source Code: https://github.com/msimerson/mail-dmarc
License: View license
1667619300
Perl 5 Cucumber
This is a minimal implementation of Cucumber in Perl5
To learn about Cucumber take a look at:
http://wiki.gihub.com/aslakhellesoy/cucumber
Feature: Dealing with mushrooms
In order to test the effect of evil poisonous mushrooms
As an evil scientist
I want to test effects of eating mushrooms on little children
Scenario: Mushrooms are bad for you, they kill boys
Given a live boy in a forest
When he ate a mushroom
Then he was a dead boy in a forest
Scenario: Mushrooms are bad for girls too
Given a live girl in a forest
When she ate a mushroom
Then she was a dead girl in a forest
Given qr/(.*) in (.*)/, sub {
my ($description,$location) = @_;
$state{human} = $description;
$state{location} = $location;
};
When qr/s?he ate (.*)/, sub {
my $item = shift;
if ($item eq 'a mushroom') {
$state{human} =~ s/live/dead/;
}
};
Then qr/s?he was (.*) in (.*)/, sub {
my ($description,$location) = @_;
is($state{human},$description,$description);
is($state{location},$location,$location);
};
$ perl p5-cucumber.pl
Feature: Dealing with mushrooms
In order to test the effect of evil poisonous mushrooms
As an evil scientist
I want to test effects of eating mushrooms on little children
Scenario: Mushrooms are bad for you, they kill boys
Given a live boy in a forest
When he ate a mushroom
Then he was a dead boy in a forest
ok 1 - a dead boy
ok 2 - a forest
Scenario: Mushrooms are bad for girls too
Given a live girl in a forest
When she ate a mushroom
Then she was a dead girl in the sea
ok 3 - a dead girl
not ok 4 - the sea
# Failed test 'the sea'
# at ./p5-cucumber.pl line 82.
# got: 'a forest'
# expected: 'the sea'
1..4
# Looks like you failed 1 test of 4.
(exitcode is 1 for failure)
And when we fix the story:
$ perl p5-cucumber.pl
Feature: Dealing with mushrooms
In order to test the effect of evil poisonous mushrooms
As an evil scientist
I want to test effects of eating mushrooms on little children
Scenario: Mushrooms are bad for you, they kill boys
Given a live boy in a forest
When he ate a mushroom
Then he was a dead boy in a forest
ok 1 - a dead boy
ok 2 - a forest
Scenario: Mushrooms are bad for girls too
Given a live girl in a forest
When she ate a mushroom
Then she was a dead girl in a forest
ok 3 - a dead girl
ok 4 - a forest
1..4
(exitcode is 0 for success)
Great thank you for the perl-il and perl-qa mailing lists
for helping me with some high level perl concepts that make
this code so beautiful like it is.
Another huge thank you to the people in #perl @freenode.net
who helped me with sticky dereferencing and scalar/list
problems.
Author: kesor
Source Code: https://github.com/kesor/p5-cucumber
1625034420
Today I will show you How to Send E-mail Using Queue in Laravel 7/8, many time we can see some process take more time to load like payment gateway, email send, etc. Whenever you are sending email for verification then it load time to send mail because it is services. If you don’t want to wait to user for send email or other process on loading server side process then you can use queue.
#how to send e-mail using queue in laravel 7/8 #email #laravel #send mail using queue in laravel 7 #laravel 7/8 send mail using queue #laravel 7/8 mail queue example
1667570280
This module is an implementation of the "Promise/A+" pattern for asynchronous programming. Promises are meant to be a way to better deal with the resulting callback spaghetti that can often result in asynchronous programs.
use AnyEvent::HTTP;
use JSON::XS qw[ decode_json ];
use Promises qw[ collect deferred ];
sub fetch_it {
my ($uri) = @_;
my $d = deferred;
http_get $uri => sub {
my ($body, $headers) = @_;
$headers->{Status} == 200
? $d->resolve( decode_json( $body ) )
: $d->reject( $body )
};
$d->promise;
}
my $cv = AnyEvent->condvar;
collect(
fetch_it('http://rest.api.example.com/-/product/12345'),
fetch_it('http://rest.api.example.com/-/product/suggestions?for_sku=12345'),
fetch_it('http://rest.api.example.com/-/product/reviews?for_sku=12345'),
)->then(
sub {
my ($product, $suggestions, $reviews) = @_;
$cv->send({
product => $product,
suggestions => $suggestions,
reviews => $reviews,
})
},
sub { $cv->croak( 'ERROR' ) }
);
my $all_product_info = $cv->recv;
To install this module from its CPAN tarball, type the following:
perl Makefile.PL make make test make install
If you cloned the github repo, the branch releases
has the same code than the one living in CPAN, so the same Makefile
dance will work. The master
branch, however, needs to be built using Dist::Zilla:
dzil install
Be warned that the Dist::Zilla configuration is fine-tuned to my needs, so the dependency list to get it running is ludicrously huge. If you want a quick and dirty install, you can also do:
git checkout releases -- Makefile.PL
perl Makefile.PL
make test
make install
This module requires these other modules and libraries:
Test::More
This module optionally requires these other modules and libraries in order to support some specific features.
AnyEvent
Mojo::IOLoop
EV
IO::Async
Copyright (C) 2012-2014 Infinity Interactive, Inc.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Author: stevan
Source Code: https://github.com/stevan/promises-perl
1667771820
GraphQL - Perl implementation of GraphQL
use GraphQL::Schema;
use GraphQL::Type::Object;
use GraphQL::Type::Scalar qw($String);
use GraphQL::Execution qw(execute);
my $schema = GraphQL::Schema->from_doc(<<'EOF');
type Query {
helloWorld: String
}
EOF
post '/graphql' => sub {
send_as JSON => execute(
$schema,
body_parameters->{query},
{ helloWorld => 'Hello world!' },
undef,
body_parameters->{variables},
body_parameters->{operationName},
undef,
);
};
The above is from the sample Dancer 2 applet.
This module is a port of the GraphQL reference implementation, graphql-js, to Perl 5.
It now supports Promises, allowing asynchronous operation. See Mojolicious::Plugin::GraphQL for an example of how to take advantage of this.
As of 0.39, supports GraphQL subscriptions.
See GraphQL::Type for description of how to create GraphQL types.
GraphQL is a technology that lets clients talk to APIs via a single endpoint, which acts as a single "source of the truth". This means clients do not need to seek the whole picture from several APIs. Additionally, it makes this efficient in network traffic, time, and programming effort:
Network traffic
The request asks for exactly what it wants, which it gets, and no more. No wasted traffic.
Time
It gets all the things it needs in one go, including any connected resources, so it does not need to make several requests to fill its information requirement.
Programming effort
With "fragments" that can be attached to user-interface components, keeping track of what information a whole page needs to request can be automated. See Relay or Apollo for more on this.
GraphQL implements a system featuring a schema, which features various classes of types, some of which are objects. Special objects provide the roots of queries (mandatory), and mutations and subscriptions (both optional).
Objects have fields, each of which can be specified to take arguments, and which have a return type. These are effectively the properties and/or methods on the type. If they return an object, then a query can specify subfields of that object, and so on - as alluded to in the "time-saving" point above.
For more, see the JavaScript tutorial in "SEE ALSO".
You will need to decide how to model your system in GraphQL terms. This will involve deciding on what output object types you have, what fields they have, and what arguments and return-types those fields have.
Additionally, you will need to design mutations if you want to be able to update/create/delete data. This requires some thought for return types, to ensure you can get all the information you need to proceed to avoid extra round-trips.
The easiest way to achieve these things is to make a GraphQL::Plugin::Convert subclass, to encapsulate the specifics of your system. See the documentation for further information.
Finally, you should consider whether you need "subscriptions". These are designed to hook into WebSockets. Apollo has a JavaScript module for this.
Specifying types and fields is straightforward. See the document for how to make resolvers.
DEBUGGING
To debug, set environment variable GRAPHQL_DEBUG
to a true value.
EXPORT
None yet.
SEE ALSO
SQL::Translator::Producer::GraphQL - produce GraphQL schemas from a DBIx::Class::Schema (or in fact any SQL database)
GraphQL::Plugin::Convert::DBIC - produce working GraphQL schema from a DBIx::Class::Schema
GraphQL::Plugin::Convert::OpenAPI - produce working GraphQL schema from an OpenAPI specification
Sample Mojolicious OpenAPI to GraphQL applet
http://facebook.github.io/graphql/ - GraphQL specification
http://graphql.org/graphql-js/ - Tutorial on the JavaScript version, highly recommended. Translation to graphql-perl.
AUTHOR
Ed J, <etj at cpan.org>
BUGS
Please report any bugs or feature requests on https://github.com/graphql-perl/graphql-perl/issues.
Or, if you prefer email and/or RT: to bug-graphql at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=GraphQL. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
ACKNOWLEDGEMENTS
The creation of this work has been sponsored by Perl Careers: https://perl.careers/.
Artur Khabibullin <rtkh at cpan.org>
contributed valuable ports of the JavaScript tests.
The creation of the subscriptions functionality in this work has been sponsored by Sanctus.app: https://sanctus.app.
LICENSE AND COPYRIGHT
Copyright 2017 Ed J.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
Author: graphql-perl
Source Code: https://github.com/graphql-perl/graphql-perl