App-wsgetmail
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
lib/App/wsgetmail.pm view on Meta::CPAN
unlink $filename or warn "couldn't delete message file $filename : $!";
}
return $ok;
}
=head2 post_fetch_action($message)
Given a Message object, executes the configured post-fetch action. Returns a
boolean indicating success.
=cut
sub post_fetch_action {
my ($self, $message) = @_;
my $method = $self->_post_fetch_action;
my $ok = 1;
# check for dry-run option
if ($self->config->{dry_run}) {
warn "dry run so not running $method action on fetched mail";
return 1;
}
if ($method) {
$ok = $self->$method($message->id);
}
return $ok;
}
###
sub _build_client {
my $self = shift;
my $classname = 'App::wsgetmail::' . $self->client_class;
load $classname;
my $config = clone $self->config;
$config->{post_fetch_action} = $self->_post_fetch_action;
return $classname->new($config);
}
sub _build_mda {
my $self = shift;
my $config = clone $self->config;
if ( defined $self->config->{username}) {
$config->{recipient} //= $self->config->{username};
}
return App::wsgetmail::MDA->new($config);
}
=head1 CONFIGURATION
=head2 Configuring Microsoft 365 Client Access
To use wsgetmail, first you need to set up the app in Microsoft 365.
Two authentication methods are supported:
=over
=item Client Credentials
This method uses shared secrets and is preferred by Microsoft.
(See L<Client credentials|https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#client-credentials>)
=item Username/password
This method is more like previous connections via IMAP. It is currently
supported by Microsoft, but not recommended. (See L<Username/password|https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-authentication-flows#usernamepassword>)
=back
This section walks you through each piece of configuration wsgetmail needs,
and how to obtain it.
=over 4
=item tenant_id
wsgetmail authenticates to an Azure Active Directory (AD) tenant. This
tenant is identified by an identifier that looks like a UUID/GUID: it should
be mostly alphanumeric, with dividing dashes in the same places as shown in
the example configuration above. Microsoft documents how to find your tenant
ID, and create a tenant if needed, in the L<"Set up a tenant"
quickstart|https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-create-new-tenant>. Save
this as the C<tenant_id> string in your wsgetmail configuration file.
=item client_id
You need to register wsgetmail as an application in your Azure Active
Directory tenant. Microsoft documents how to do this in the L<"Register an
application with the Microsoft identity platform"
quickstart|https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app#register-an-application>,
under the section "Register an application." When asked who can use this
application, you can leave that at the default "Accounts in this
organizational directory only (Single tenant)."
After you successfully register the wsgetmail application, its information
page in your Azure account will display an "Application (client) ID" in the
same UUID/GUID format as your tenant ID. Save this as the C<client_id>
string in your configuration file.
After that is done, you need to grant wsgetmail permission to access the
Microsoft Graph mail APIs. Microsoft documents how to do this in the
L<"Configure a client application to access a web API"
quickstart|https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-configure-app-access-web-apis#application-permission-to-microsoft-graph>,
under the section "Add permissions to access Microsoft Graph." When selecting
the type of permissions, select "Application permissions." When prompted to
select permissions, select all of the following:
=over 4
=item * Mail.Read
=item * Mail.Read.Shared
=item * Mail.ReadWrite
=item * Mail.ReadWrite.Shared
=item * openid
=item * User.Read
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.005 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )